473,396 Members | 2,018 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Who can help me with this simple webform problem?? (SessionState)

The idea behind this code is to standardize all my webpages in an
application to look the same by inheriting the pages from a userdefined
class. But it gives me problems regarding sessionstate...

Try creating a new asp.net web application in Visual Studio .NET 2003 on
Framework 1.1 using VB language

Call the project testform

add a new webform called "atest.aspx"

insert this code into atest.aspx:
--------------------------------
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="atest.aspx.vb"
Inherits="testform.atest"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>atest</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<P><asp:DropDownList id="DropDownList1"
runat="server"></asp:DropDownList></P>
<P><asp:TextBox id="TextBox1" runat="server"></asp:TextBox></P>
<P><asp:Button id="Send" runat="server" Text="Button"></asp:Button></P>
</form>
</body>
</HTML>
--------------------------------

and insert this code into atest.aspx.vb
--------------------------------
Public Class atest
Inherits System.Web.UI.Page
'Inherits MyPage
Protected WithEvents DropDownList1 As
System.Web.UI.WebControls.DropDownList
Protected WithEvents Send As System.Web.UI.WebControls.Button
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If IsPostBack Then
Else
With DropDownList1
.Items.Add("Item1")
.Items.Add("Item2")
.Items.Add("Item3")
.Items.Add("Item4")
End With
End If
End Sub

End Class

Public Class MyPage
Inherits System.Web.UI.Page

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim theform As Control = Page.FindControl("Form1")
Dim cntrl As Label = New Label : cntrl.Text = "My header<hr>"
theform.Controls.AddAt(0, cntrl)
cntrl = New Label : cntrl.Text = "<hr>My footer"
theform.Controls.AddAt(theform.Controls.Count, cntrl)
End Sub

End Class
--------------------------------

compile and run it.

Try selecting item number 3 and put some text into the textbox - click send.

OK - the page reloads and keeps the sessionstate (item3 is still selected
and the textbox is unchanged)

Then try moving the ' in line 3 of atest.aspx.vb so the two lines says:
'Inherits System.Web.UI.Page
Inherits MyPage

Compile and run it and do the above test again...

Now the dropdown loses its sessionstate but the textbox seems to survive!!

What am I doing wrong!!
Nov 17 '05 #1
0 1097

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Brian Conway | last post by:
I have no idea what is going on. I have a Login screen where someone types in their login information and this populates a datagrid based off of the login. Works great in debug and test through...
2
by: John A Grandy | last post by:
for the code-behind a WebForm, it's easy to use ASP.NET session state -- just refer to the built-in Session object ... but how to write code elsewhere that utilizes this same object ? within a...
3
by: Kris van der Mast | last post by:
Hi, I've created a little site for my sports club. In the root folder there are pages that are viewable by every anonymous user but at a certain subfolder my administration pages should be...
1
by: Edward Smit | last post by:
Dear all I've found a problem with raising server-events from a LinkButton (although I suspect that other Controls have the same problem). It appears that if you set the ID property with a string...
17
by: jensen bredal | last post by:
Hello, i'm struggling with a somehow badly understood session scenario. I provide acces to my pages based on form authentication using Session cookies. Som of my pages are supposed to be...
1
by: serge calderara | last post by:
Dear all, I have created a simple user control (server Button) with a public property define has follow: Public Property value() As Integer Get 'return value Return ViewState("Value") End...
2
by: Joshua Tan | last post by:
hey there, I really need some help with this. I have a web application running on Windows 2000 Server , IIS5.0 , .Net Framework 1.1 I have a file.aspx, file.aspx.cs and file.aspx.resx I...
2
by: momo | last post by:
Hello Guys, I have a bit of a problem, I created a Dll called SecureQueryStringDll.dll and I had the dll put bin folder of my application first and it did not work so I then put it in the bin...
4
by: samadams_2006 | last post by:
Hello, I have a peculiar problem that I'm hoping someone can help me out with. I have a simple enough Web Application written in VB.Net via Visual Studio 2003. It simply displays a Web Form...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.