473,770 Members | 2,719 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="ate st.aspx.vb"
Inherits="testf orm.atest"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>atest</title>
<meta name="GENERATOR " content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<P><asp:DropDow nList id="DropDownLis t1"
runat="server"> </asp:DropDownLis t></P>
<P><asp:TextB ox id="TextBox1" runat="server"> </asp:TextBox></P>
<P><asp:Butto n 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.P age
'Inherits MyPage
Protected WithEvents DropDownList1 As
System.Web.UI.W ebControls.Drop DownList
Protected WithEvents Send As System.Web.UI.W ebControls.Butt on
Protected WithEvents TextBox1 As System.Web.UI.W ebControls.Text Box

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
If IsPostBack Then
Else
With DropDownList1
.Items.Add("Ite m1")
.Items.Add("Ite m2")
.Items.Add("Ite m3")
.Items.Add("Ite m4")
End With
End If
End Sub

End Class

Public Class MyPage
Inherits System.Web.UI.P age

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim theform As Control = Page.FindContro l("Form1")
Dim cntrl As Label = New Label : cntrl.Text = "My header<hr>"
theform.Control s.AddAt(0, cntrl)
cntrl = New Label : cntrl.Text = "<hr>My footer"
theform.Control s.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.P age
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 1120

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

Similar topics

10
2724
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 VS, however, when I change to release and put it out on the web it fails giving me the following error message The underlying connection was closed. Could not establish a trust relationship with the remote server.
2
1544
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 WebForm, Session is an instance of the class System.Web.SessionState.HTTPSessionState .... but how to refer to this same object outside of a WebForm's code-behind ?
3
4870
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 protected by forms authentication. When I create forms authentication at root level it works but when I move my code up to the subfolder I get this error: Server Error in '/TestProjects/FormsAuthenticationTestingArea' Application.
1
1045
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 containing "$" that the Server-Side events aren't fired. This is probably caused by the fact that the Javascript __doPostBack expects the $-sign to be used for some Control-identification magic. Now if this is the case I would expect ASP.Net to...
17
5216
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 running continuously and refreshing once an hour. I there set timeout= 61 in <sessionState section and on my page it says <meta http-equiv="refresh" content="3600">. I also set timeout=120 in the <forms section of web.config to make sure
1
1101
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 Get
2
1425
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 tried changing some simple code in the .cs but the changes do not reflect on the webpage. Someone told me I need to recompile. Is there anywork around?
2
1920
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 folder of c:\inetpub\wwwroot and it still does not work. Here is the error I get from it: temporary asp.net files\root\d16a94c5\8b912d73\assembly\dl2\1dc1ef5c\006575a4_827ac301\metabuilders.webcontrols.rowselectorcolumn.dll"...
4
1433
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 with a label field saying "Hello". When I run this application interactively via Visual Studio 2003, I have no problems. When I transfer this code to my Web Site and type in the URL: : http://www.certify-it.com/Test/test1.aspx , it give me the
0
9453
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10254
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10099
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10036
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9904
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8929
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.