Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   How do I get a page to maintain control states? (http://www.velocityreviews.com/forums/t96835-how-do-i-get-a-page-to-maintain-control-states.html)

Tom wilson 02-16-2005 06:46 PM

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!


Patrice 02-16-2005 07:27 PM

Re: How do I get a page to maintain control states?
 
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" <yeahright@nospam.com> a écrit dans le message de
news:pv4711hdqr8d679vu10t1qg4d14h13nqvp@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!
>




Tom wilson 02-16-2005 08:05 PM

Re: How do I get a page to maintain control states?
 
">- 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, ****ed.

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" <nobody@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



Chad Devine 02-16-2005 09:00 PM

Re: How do I get a page to maintain control states?
 
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.


Juan T. Llibre 02-16-2005 09:27 PM

Re: How do I get a page to maintain control states?
 
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" <surr3al@gmail.com> wrote in message
news:1108587654.904395.178010@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.
>




Tom wilson 02-16-2005 09:36 PM

Re: How do I get a page to maintain control states?
 
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" <surr3al@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.



Chad Devine 02-16-2005 09:37 PM

Re: How do I get a page to maintain control states?
 
Or perhaps no web.config exists, which could also result in this
problem.


Juan T. Llibre 02-16-2005 09:42 PM

Re: How do I get a page to maintain control states?
 
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" <surr3al@gmail.com> wrote in message
news:1108589830.152483.298700@z14g2000cwz.googlegr oups.com...
> Or perhaps no web.config exists, which could also result in this
> problem.




Tom wilson 02-16-2005 09:49 PM

Re: How do I get a page to maintain control states?
 
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"
<nomailreplies@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" <surr3al@gmail.com> wrote in message
>news:1108587654.904395.178010@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.
>>

>



Chad Devine 02-16-2005 10:04 PM

Re: How do I get a page to maintain control states?
 
You're right Juan, which means this is truly a strange problem. Anyway,
glad it worked... now to figure out why it worked, ha.



All times are GMT. The time now is 03:24 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.