473,503 Members | 338 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Very simple viewstate question

In VS2003 - add a page.
Add a button
Add a textbox.

Set EnableViewState = False for all 3 above.

Put some code behind on Button (anything).

Run the sample - type something in the textbox - hit the button - ..
viewstate is false .. the textbox after postback should contain nothing ..!!

Unfortunately the value of the textbox remains .. What is going on??

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
http://blogs.apress.com/authors.php?author=Sahil Malik


Nov 19 '05 #1
3 1141
Textboxes maintain their state without viewstate. That's because they don't
need viewstate to be persistant - their values are automatically submitted
via the form. You might think the same is true for a dropdown, but only the
selected value is passed in the form which is why disabling viewstate for it
(or other controls) makes the value disapear.

you'll need to manually set it to ""

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Sahil Malik" <co*****************@nospam.com> wrote in message
news:Od**************@TK2MSFTNGP11.phx.gbl...
In VS2003 - add a page.
Add a button
Add a textbox.

Set EnableViewState = False for all 3 above.

Put some code behind on Button (anything).

Run the sample - type something in the textbox - hit the button - ..
viewstate is false .. the textbox after postback should contain nothing ...!!
Unfortunately the value of the textbox remains .. What is going on??

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
http://blogs.apress.com/authors.php?author=Sahil Malik

Nov 19 '05 #2
Textbox's along with some other server controls maintain their state by
default. Viewstate is not the reason for it. These server controls implement
IPostBackDataHandler interface. Thats the reason how they are able to
persist the data. There was a similar thread started yesterday on the
asp.net forums.
http://asp.net/Forums/ShowPost.aspx?...&PostID=772553

--
Kumar Reddi
http://kumarreddi.blogspot.com

"Sahil Malik" <co*****************@nospam.com> wrote in message
news:Od**************@TK2MSFTNGP11.phx.gbl...
In VS2003 - add a page.
Add a button
Add a textbox.

Set EnableViewState = False for all 3 above.

Put some code behind on Button (anything).

Run the sample - type something in the textbox - hit the button - ..
viewstate is false .. the textbox after postback should contain nothing ...!!
Unfortunately the value of the textbox remains .. What is going on??

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
http://blogs.apress.com/authors.php?author=Sahil Malik

Nov 19 '05 #3
Thanks guys !!!

- SM

"Sahil Malik" <co*****************@nospam.com> wrote in message
news:Od**************@TK2MSFTNGP11.phx.gbl...
In VS2003 - add a page.
Add a button
Add a textbox.

Set EnableViewState = False for all 3 above.

Put some code behind on Button (anything).

Run the sample - type something in the textbox - hit the button - ..
viewstate is false .. the textbox after postback should contain nothing ...!!
Unfortunately the value of the textbox remains .. What is going on??

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
http://blogs.apress.com/authors.php?author=Sahil Malik

Nov 19 '05 #4

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

Similar topics

3
3664
by: Kevin Gorski | last post by:
This question has been asked before, but there have been no definitive answers that I was able to find. Can the viewstate hidden input field be moved to a less prominent page location? On an...
7
2012
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...
6
1745
by: msnews.microsoft.com | last post by:
Hello All, I am very new to ASP.NET and I have a basic question. Can somebody please explain? I have an .aspx Web Page with a textbox control. When the Page initially loads I am calling a...
6
2723
by: John | last post by:
Hi all, I am using dynamic user controls within my web app and these controls are loaded into placeholders via the LoadControl method. My problem is this: I have usercontrolA loaded into a...
9
1848
by: Mark Broadbent | last post by:
Been a while since I've touched asp.net but one thing that always seems to fustrate me is the loss of state on variable declarations. Is there anyway (i.e. assigning an attribute etc) to instruct...
11
2462
by: Nad | last post by:
Hello, I have a page with two link buttons. When I click on the first one I call server.execute("target.aspx") to view target.aspx on the original page. Then I click on the second link button...
1
1949
by: Mark Olbert | last post by:
I have a "master" composite control which, in turn, holds an instance of a "detail" composite control (the "master" control will ultimately contain multiple instances of the "detail" control, but...
3
3012
by: Justin | last post by:
I have aspx pages with 10 checkboxlist controls. total individual checkbox (the sum of individual checbox in those 10 checkboxlists) on the page is about 1710. You can imagine how large the...
9
2654
by: =?Utf-8?B?TUNN?= | last post by:
I'm sure the answer to my question varies depending on the situation, but I am looking for a general "best practice". If I have an asp.net application and I load certain data from a database,...
0
7087
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...
1
6993
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
7462
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...
1
5014
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
4675
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
3168
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
3156
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1514
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 ...
1
737
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.