Why the value of textbox get preserved after post back even if viewstate property is false?

Hi All,
        I have simple aspx page  whch contains one textbox and one button.Enable viewstate property of textbox is false .Both textbox and buttons are server controls.When I view the page in browser and add some string in textbox and after clicking on button it get post back and text box shows me a same value even if enable view state property of that text box is false.
What is the reason behind it?
 Idealy it should not preserve the value as enable view state is false.

I am just using my free time,but if it helps you then my mark my post as answer
5/7/2008 1:11:17 PM
📁 asp.net.state-management
📃 8807 articles.

💬 5 Replies

I think I have the same problem and I can't figure out, why after postback im still showing my value.
I have a textbox that when I enter 0 it deletes that record.Now instead of showing me an empty textbox, after deleting the record, it shows me a 0. If I refresh or do a postback then it shows me an empty textbox. Why is this? I tho by using EnableViewState="false" this value should not be preserve...?
5/7/2008 1:40:31 PM

That's because in case of textboxes, the values get submitted to the server on every postback and are available in teh Request.forms[] collection. Hence despite of the viewstate being disabled for textboxes, the value is fetched from the Request.forms collection and displayed.
Suprotim Agarwal

ASP.NET Grid With Excel Capabilities | 27 GridView Tips & Tricks  | Hosting your site? |  SQL Server Tips
5/7/2008 1:46:12 PM

How can I stop the textbox from retaining that value? Is misleading the right information
5/7/2008 2:02:42 PM

 You can't stop it from having the value it should have, because that is how post requests in web forms are working. If you need to know the old value (default value, prior you typed something in textbox) you can obtain it in OnInit and save it there in some private variable and then restore the value of textbox back to the old value in PageLoad.

Blog: http://blogs.mscommunity.net/blogs/borissevo/

Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post fixed your problem.
5/7/2008 2:12:52 PM

How can I stop the textbox from retaining that value? Is misleading the right information

simply , set its Text proeprty to an empty string like this :
Actually , we discuss this before , have a look
Best Regards,


Anas Ghanem.

Note:Please Don't hesitate to click "Report Abuse" link if you noticed something wrong on the forums (like duplicate ,Off-topic,offensive,or any post that violates the website "TERMS OF USE"). -- Thanks!

5/7/2008 8:06:35 PM

Similar Artilces: