473,668 Members | 2,491 Online
Bytes | Software Development & Data Engineering Community
+ 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:Text Box id="TextBox1"
runat="server"> </asp:TextBox>
</p>
<p>
&nbsp;<asp:Butt on 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 1863
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*******@nosp am.com> a écrit dans le message de
news:pv******** *************** *********@4ax.c om...
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:Text Box id="TextBox1"
runat="server"> </asp:TextBox>
</p>
<p>
&nbsp;<asp:Butt on 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.goo glegroups.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.goo glegroups.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.go oglegroups.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

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

Similar topics

1
361
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 textbox control, but whenever i click the button it adds only one textbox control to the page. How can i add multiple controls to the placehoder control on postback & also maintain viewstate state of the previously added controls. I tried doing...
4
3937
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 using the IndexOf method of the list's items collection (in my debugging case this successfully sets the selectedindex to 15). After postback, the selecteditem is always the first item in the list, losing the selection I set previously (And
2
1986
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 the client, it regenerates the string very time this control appears on a page. Is there a way to create this string ONCE and then just use if every time after that? CODE
6
6008
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 create 1-n datagrids. When the Submit button is clicked I need to save (in viewstate) the contents of the criteria controls so that I can recreate the dynamic DataGrid(s) in the LoadViewState (overloaded method). I need to do this so that the...
7
2031
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 Button1.Click Response.Redirect("login.aspx") End Sub Very simple. Forget what login.aspx does, it's just somewhere to redirect to.
1
1526
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 I've discovered is that my problem seems to lie entirely with IE. A bit of history... My app is an online survey. The questions, choices and so on are
3
5196
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 SiteMaptDataSource (Web.sitemap) for both, but only have 1/2 of the nodes visible in the TreeControl, and have ALL the nodes visible in the Breadcrumb? We could maintain two Web.sitemaps, but that sounds like a annoying maintenance issue. Thanks...
7
1745
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. I have a simple page that I made in the beta2 version of VWD. The code behind looks like... using System;
7
2289
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 FindControl the only way to do it?
0
8381
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
8799
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...
0
8658
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
7401
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
5681
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4205
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
4380
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2792
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 we have to send another system
2
1786
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.