473,465 Members | 1,920 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How do I get a page to maintain control states?

This is the same topic as the thread above, "Dealing with the Back
button". I'm getting nowhere. The closest I've come is a sample left
for me:

<%@ Page Language="vb" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
</head>
<body>
<form runat="server" ID="Form1">
<p>
&nbsp;<asp:TextBox id="TextBox1"
runat="server"></asp:TextBox>
</p>
<p>
&nbsp;<asp:Button id="Button1" runat="server"
Text="Button"></asp:Button>
</p>
</form>
</body>
</html>

1 - Load the page, enter something in the text box.
2 - Hit submit
3 - Click Back
4 - The string you entered remains.

When I put this code, in its entirety, into a new .aspx page and run
it, the textbox is blank after hitting the back button.

Why, and how can I prevent it? (before I go completely insane)

Thanks!

Nov 19 '05 #1
12 1842
I don't see what difference you make between point 1 to 4 and the later
scenario (not clear if you used submit before using the back button).

IMO :
- if something is wrong I would redisplay the whole form with the error
message so that the user doesn't even have to use the back button. Keep in
mind that you would rely here on a client side behavior that the user could
have altered (by changing its IE settings).

- for now I have the behavior you described in point 1 to 4. Could it be a
problem with your cache ? I would try to add a date/time information to the
page to see if the page with blank fields comes from the IE cache or if IE
gets it once again from the server. It could be also a IE settings. For now
it looks liike that when you using the back button, IE gets the page again
(AFAIK it was also the behavior on old IE releases, whcih version are you
using).

Good luck.

Patrice
--

"Tom wilson" <ye*******@nospam.com> a écrit dans le message de
news:pv********************************@4ax.com...
This is the same topic as the thread above, "Dealing with the Back
button". I'm getting nowhere. The closest I've come is a sample left
for me:

<%@ Page Language="vb" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
</head>
<body>
<form runat="server" ID="Form1">
<p>
&nbsp;<asp:TextBox id="TextBox1"
runat="server"></asp:TextBox>
</p>
<p>
&nbsp;<asp:Button id="Button1" runat="server"
Text="Button"></asp:Button>
</p>
</form>
</body>
</html>

1 - Load the page, enter something in the text box.
2 - Hit submit
3 - Click Back
4 - The string you entered remains.

When I put this code, in its entirety, into a new .aspx page and run
it, the textbox is blank after hitting the back button.

Why, and how can I prevent it? (before I go completely insane)

Thanks!

Nov 19 '05 #2
">- if something is wrong I would redisplay the whole form with the
error message so that the user doesn't even have to use the back
button."

That sounds logical, doesn't it? My main app works this way. You get
your form, fill stuff out and submit. The page returns to the browser
with red error texts above each 'errored' control. Its a work of art.
You can submit repeatedly until all errors disappear. I'm proud.

But click back anywhere during this process, even after 5 submits, the
page is returned blank. Come on, you know SOMEbody is going to click
the back button and call me up, pissed.

So I tried your time example as suggested below:

- Load form. Time is: 2:53:12
- Enter text, submit
- Time is 2:53:33
- Click "Back"
- Time is: 2:53:12

I assume the page is coming from IE's cache cause the time is the same
when going back. If it came from the server the time would be past
2:53:33, right?

So this means... asp.net pages are not capable of maintaining state?
:)

Or that IE is somehow killing the page state when it reloads the page
from its cache?

Nothing is making any sense.

(thx for the reply!)


On Wed, 16 Feb 2005 20:27:11 +0100, "Patrice" <no****@nowhere.com>
wrote:
I don't see what difference you make between point 1 to 4 and the later
scenario (not clear if you used submit before using the back button).

IMO :
- if something is wrong I would redisplay the whole form with the error
message so that the user doesn't even have to use the back button. Keep in
mind that you would rely here on a client side behavior that the user could
have altered (by changing its IE settings).

- for now I have the behavior you described in point 1 to 4. Could it be a
problem with your cache ? I would try to add a date/time information to the
page to see if the page with blank fields comes from the IE cache or if IE
gets it once again from the server. It could be also a IE settings. For now
it looks liike that when you using the back button, IE gets the page again
(AFAIK it was also the behavior on old IE releases, whcih version are you
using).

Good luck.

Patrice


Nov 19 '05 #3
You do not have:
<%@ Page EnableViewState="True" %>
at the top of your .aspx page.

You do have:
<%@ Page Language="vb" %>

So just add on the EnableViewState like this:
<%@ Page Language="VB" EnableViewState="True" %>

That will enable your page to keep the form information.

Nov 19 '05 #4
Unless EnableViewState has been explicitly set to "false"
in web.config, the default setting is "true", so setting it to
"true" should not affect the page's ViewState settings.

But, maybe it *was* set to "false" in web.config... :-)

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
=====================

"Chad Devine" <su*****@gmail.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
You do not have:
<%@ Page EnableViewState="True" %>
at the top of your .aspx page.

You do have:
<%@ Page Language="vb" %>

So just add on the EnableViewState like this:
<%@ Page Language="VB" EnableViewState="True" %>

That will enable your page to keep the form information.

Nov 19 '05 #5
Or perhaps no web.config exists, which could also result in this
problem.

Nov 19 '05 #6
OMG, it works.

This tiny example works, my main app does not.

But that's the solution to my small example. You may now feel
intellectually superior. :)

for x=1 to 1000000
response.write("THANKS!!!!<BR>")
Next

On 16 Feb 2005 13:00:54 -0800, "Chad Devine" <su*****@gmail.com>
wrote:
You do not have:
<%@ Page EnableViewState="True" %>
at the top of your .aspx page.

You do have:
<%@ Page Language="vb" %>

So just add on the EnableViewState like this:
<%@ Page Language="VB" EnableViewState="True" %>

That will enable your page to keep the form information.


Nov 19 '05 #7
Hmm...

It's set in machine.config ( in both v1.1 and v2.0 ).
I don't remember about v1.0, but think it was.

It's interesting to note that setting it to "true" *did* work,
so *someone* must have fiddled with that setting ... ;-)

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
=====================

"Chad Devine" <su*****@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Or perhaps no web.config exists, which could also result in this
problem.

Nov 19 '05 #8
You would think. There's nothing about viewstate in web.config, I
assume that means its enabled by defualt. I have checked many times,
the properties of the form and the controls and all their viewstate
properties are set to True. But this example (single textbox) would
not work....

*WITH Internet Explorer ONLY*

Interesting, huh? Firefox and Netscape 7.1, after clicking submit and
then clicking Back, retained the value in the textbox. IE did not,
until I added that line below to enable the viewstate.

My main app does something similar but it's far more complicated; it
does a submit postback, checks for entry errors and returns the page
with error texts inserted into the pageholder sequence. It works
perfectly going forward but go back and everything is lost.

I still have to do somthing about that, I can't have users killing
page after page of data entry with a single click. Usually it's "Page
has expired", at which point you have to go "Back" until you're at the
first iteration of the page. Hmm...


On Wed, 16 Feb 2005 17:27:18 -0400, "Juan T. Llibre"
<no***********@nowhere.com> wrote:
Unless EnableViewState has been explicitly set to "false"
in web.config, the default setting is "true", so setting it to
"true" should not affect the page's ViewState settings.

But, maybe it *was* set to "false" in web.config... :-)

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
=====================

"Chad Devine" <su*****@gmail.com> wrote in message
news:11**********************@c13g2000cwb.googleg roups.com...
You do not have:
<%@ Page EnableViewState="True" %>
at the top of your .aspx page.

You do have:
<%@ Page Language="vb" %>

So just add on the EnableViewState like this:
<%@ Page Language="VB" EnableViewState="True" %>

That will enable your page to keep the form information.


Nov 19 '05 #9
You're right Juan, which means this is truly a strange problem. Anyway,
glad it worked... now to figure out why it worked, ha.

Nov 19 '05 #10
>From what I know about viewstate, if your form is posting to another
page, all the view state information will be lost. So, in that case you
may have to use session state variables or something... Perhaps Juan
knows of something easier than throwing all form fields into session
state.

Nov 19 '05 #11
Humm... Is it solved ?

Sounds really strange to me it was the viewstate as when the page is loaded
from the cache there is AFAIK no code that runs...

I disabled viewstate on my test page and still have the same behavior (i.e.
when the page is submitted and when I click on the back button, form fields
are left intact). I'm using IE6.

Patrice

--

"Tom wilson" <ye*******@nospam.com> a écrit dans le message de
news:ej********************************@4ax.com...
OMG, it works.

This tiny example works, my main app does not.

But that's the solution to my small example. You may now feel
intellectually superior. :)

for x=1 to 1000000
response.write("THANKS!!!!<BR>")
Next

On 16 Feb 2005 13:00:54 -0800, "Chad Devine" <su*****@gmail.com>
wrote:
You do not have:
<%@ Page EnableViewState="True" %>
at the top of your .aspx page.

You do have:
<%@ Page Language="vb" %>

So just add on the EnableViewState like this:
<%@ Page Language="VB" EnableViewState="True" %>

That will enable your page to keep the form information.

Nov 19 '05 #12
Actually, no. My main app works flawlessly in Netscape and Firefox.
In IE, the back button will lose all data every time. See my post
farther down. :)
On Thu, 17 Feb 2005 11:09:59 +0100, "Patrice" <no****@nowhere.com>
wrote:
Humm... Is it solved ?

Sounds really strange to me it was the viewstate as when the page is loaded
from the cache there is AFAIK no code that runs...

I disabled viewstate on my test page and still have the same behavior (i.e.
when the page is submitted and when I click on the back button, form fields
are left intact). I'm using IE6.

Patrice


Nov 19 '05 #13

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

Similar topics

1
by: Prasad Patil | last post by:
Hi, I ahave a web page, on which i have a placeholder control, a button control .. When i click on the button control it shoul add a user control to the placeholder control. I tried the same with...
4
by: Justin Bartels | last post by:
Hi, I have been struggling with an unusual problem with a dropdownlist web control for quite some time now. Cutting straight to the problem, I am setting the selected item in the dropdownlist...
2
by: Earl Teigrob | last post by:
I have a Web Custom Control that builds javascript to write to the page. The DatePickerJs() function builds over 500 lines of javacript code. Even thought my Custom Web Control does not write it to...
6
by: Glenn Owens | last post by:
I have an ASP.Net page on which there are serveral static controls (listboxes, radiobuttonlist and textboxes). These controls are used to create criteria from which the code-behind will dynamically...
7
by: Tom wilson | last post by:
I have created a very simple example that doesn't work. Form1 contains a textbox and a button: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles...
1
by: Tom wilson | last post by:
Yes, I'm sorry, it's me again. :) Yesterday I went through hell trying to figure out why my aspx pages wouldn't maintain state. I had a simple example I (we) eventually got to work. What...
3
by: Mark | last post by:
I can envision a situation where I want part of our site to be navigated using a TreeView, and ALL of our site to have a Breadcrumb (SiteMapPath control). Is there a way to maintain a single...
7
by: Alan Silver | last post by:
Hello, I have installed the 2.0 framework, and am looking at converting some of my 1.1 pages to use partial classes. I don't (yet) have VS2005, so I'm doing this by hand, but am having problems....
7
by: Andy B | last post by:
I have a class I am creating for data access. I need to access controls from inside the class that are on a particular page. How do I do this? or is creating an instance of the page class and using...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.