473,657 Members | 2,300 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 1155
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.co m> wrote in message
news:Od******** ******@TK2MSFTN GP11.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
IPostBackDataHa ndler 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.co m> wrote in message
news:Od******** ******@TK2MSFTN GP11.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.co m> wrote in message
news:Od******** ******@TK2MSFTN GP11.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
3679
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 otherwise well-optimised page a large viewstate can be detrimental to it's page-ranking since the content is pushed further from the beginning of the document. Thanks for any help.
7
2029
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.
6
1755
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 Javascript function to write a text information in the text box.
6
2739
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 placholder and the user clicks on a specific control outside of the usercontrol and some Javascript is run where a hidden variable is changed to reflect another usercontrol (usercontrolB).
9
1862
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 the server to remember a variables state *without* having to go through the rigmarole of saving and loading to and from the Session state manually or similar workaround for any Types (including custom types) in exactly the same way web controls...
11
2472
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 and in this case I redirect to another page, HOWEVER, I get Invalid ViewState exception. I know the problem stems from server.execute but don't know why. Any Ideas? Thank you.
1
1968
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 I'm keeping things simple to try and figure out what's going wrong). The master control supports databinding. Upon postback, the detail control is not retrieving its state from ViewState after it is created and added to the master control during...
3
3028
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 viewstate is. Is there anyway I can shrink the viewstate and at the same time get the values of each checkbox after postback? Thanks
9
2666
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, should I use ViewState to store and reload the data, or should I load the data from the database on each postback? Assume for the sake of this question that I only care about performance, I don't care about ease of programming.
0
8411
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8323
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
8739
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
8513
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
8613
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
7351
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...
1
6176
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4173
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
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.