ViewState Remains as it is even if I explicitly false it in my textbox.

Hi All,

I have a simple form in C# (ASP.NET 2.0) web application and on that I have taken one textbox and a button.
<asp:TextBox ID="txttest" runat="server" EnableViewState="false"></asp:TextBox>
<asp:Button ID="btntest" runat="server" Text="Test" />

Now execute this page and write anything in text box say "Hello" and click on a button.
Here I have written EnableViewState="False" then also when I click on button, it refreshes the page and re-filling "Hello" in that textbox.
If we see practically it should not be filled because viewstate is not maintained in this case.

Is anybody have any idea why this is happening ?
Also if this is the case then what do I do to remove this value while postback.

Thanks in Advance.


Please Mark this as an Answer if it resolves your problem.
6/16/2008 7:19:50 AM 8807 articles. 0 followers. Follow

6 Replies

Similar Articles

[PageSpeed] 45

Check out this article..;en-us;316813

Virendra (MCTS)

My SiteBlog
6/16/2008 8:10:24 AM

 Hi Virendra,

Thanks very much for your reply.
I know that this is happening but I don't want it to maintain means I want it to be removed when click on Button.
Please suggest if you have any idea about to do this.



Please Mark this as an Answer if it resolves your problem.
6/16/2008 9:30:11 AM

You explicitly need to clear the value on button click.

TextBox1.Text = String.Empty; 

You can do thru java script also.

In Java script..
document.getElementByID('textbox1').value = '';

Virendra (MCTS)

My SiteBlog
6/16/2008 9:47:52 AM

If we see practically it should not be filled because viewstate is not maintained in this case.

hello,mit_ce. you should understand the resaon why the textbox's text is refilled. Its being refilled has no relationship with the value of EnableViewState, that means it is not the textbox's view state that refills the text property. Why?

textbox's text property value is a kind of post data(data entered by user), so it is of course sent to the web server everytime postback occurs. So, generally, the web server doesn't have to remember textbox's text property's value.

What really matters most is the chance to communicate with you, my friends, rather than marking my post as answer, though I would be really appreciated if you do so.
6/19/2008 4:15:17 AM

There are two different statecontrols in ASP .NET 2.0

1) Viewstate

2) ControlState

Viewstate is optional and often contains the state of the control. Whilst controlstate is always on (except explicitly turned off) and contains information about the control that is critical for its use. Now, some controls store their value inside the controlstate. Which means that what you type inside the textbox, will be there after the postback even if viewstate is turned off. You should lookup the controls in msdn library to check if it stores information inside controlstate or viewstate.


6/19/2008 10:26:36 AM

Similar Artilces:

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.SuyogI am just using my free time,but if it helps you ...

Is ViewState still validated even when enableViewState="False" enableViewStateMac="False"
Does a aspx page get validated on the web server even if enableViewState="False" enableViewStateMac="False"? Thanks....   Pete A wrote: Does a aspx page get validated on the web server even if enableViewState="False" enableViewStateMac="False"? What do you mean by "Page get validated". Are you talking about the server side validation?Kumar Reddi If a web control depends on the ViewState (i.e. DropDownList) then you will have issues. So, you will also have issues with validation if ViewState is disabled.Ryan OlshanASPInsider | Microsoft MVP, ASP.NEThttp://ryanolshan...

State Management; .Net Profiler
Here is the situation with the customized profiler. I got a profiler class called SSOProfileProvider inheriting from ProfileProvider. I've implemented the Initilization, GetPropertyValues and SetPropertyValues. The Get... and Set.. are making a call to the database to store profile into the database. This class has been stored in the separate DLL called "Security.DLL" and there is a web site that is using this dll. The web.Config for this website is as follow:<profile enabled="true" inherits="AppProfileBase" defaultProvider="SSO" automat...

Huge ViewState in GridView even when EnableViewState=False
Hello, what can I do to reduce the ViewState in the GridView?I have EnableViewState=false and I have about 100 rows whithout paging.I also have this in my GridView-Code:...<asp:TemplateField ><ItemStyle wrap="False" horizontalalign="Right" /><ItemTemplate><asp:imagebutton runat="server" imageurl="edit.gif" alternatetext="Edit" commandname="edit"     causesvalidation="false" id="btnEdit"></asp:imagebutton><asp:imagebutton runat="server" id="btnDelete" imageurl="del.gif" alternatetext="Delete"     command...

allow scrolling on a .net textbox where enabled=False
I need to modify a .net textbox to allow it to be scrollable.1 <div style="overflow: auto; width: 100px;"> 2 <asp:TextBox ID="txtTestParent" runat="server" Width="100px" Height="30px" Enabled="False"> 3 </asp:TextBox> 4 </div> but the problem that i have is because the textbox is enabled i cannot scroll and see the text thats to the right .I cannot change the screensize, textbox size and I must keep the control so its enabl...

Alternative for Viewstate to store Dataset? + State management
Hi,         In my application, we are handling dataset/datatable to enable the gridview paging/sorting functionality. hence the dataset/datatabel object are stored in Viewstate to avoid the DB call on every page click or sorting. Now the problem is viewstate size, because in my application we may have more than one gridview so that the datset size also increased and viewstate size also increased to 1 MB.                1. How to reduce the viewstate size? or What is gobal norms for Vie...

Configuration: Debug .NET even when configuration is Release and debug=false
All -- Please help. Why does the Output Window say "Configuration: Debug .NET" for a web site project when I have set the build configuration in the VS.NET IDE to "Release" and I have set <compilation defaultLanguage="c#" debug="false" /> in the Web.config file? Here are the details. I have a VS.NET 2005 SP1 Solution. The Solution contains 6 ClassLibrary projects. The Solution contains 1 web-site project in it. I am using C#.NET for all projects. In the VS.NET IDE, I have set the build configuation to "Release". In the Web.config file I have set <compil...

Opinions on Viewstate vs. Session variable for state management on dataset
I came across many sample codes that using ViewState(myDataSet) and Session("myDataSet"). Which is a better way to use to keep the session around. What are the pros and cons? Anybody can share with your experience or thoughts? Thanks, teresa Take a loot at this article: State Management in Web Forms Norton, MVPDarrell Norton's BlogPlease mark this post as answered if it helped you!...

ispostback is false even when it is not suppose to be false
I got this form with several panels and buttons to go back and forward. I initiate a variable inside the page_load, like this: <script runat="server"> dim s as integer sub page_load if not ispostback then    s=0 end if end sub </script> Somehow, whenever a forward button or previous button is clicked, it will execute s=0. I followed each step and it looks like ispostback is always false in this case. Any suggestions? Thanks. dim s as integer s is never given an initial value, so, it's default value is 0, even on a postback. Zath Where is it tha...

Microsoft Chart control for .NET Framework about state management and serialization problem, it works OK with one XML file but fails with another XML file
I use Microsoft Chart control for .NET Framework , you can see details at The Chart1 is load data from a xml and save to ViewStateData, so even if after I click Reload button, the chart1 still display OK! I'm very strange that the chart1 works well after click Reload button if it's loaded from Chart1.Serializer.Load(HttpContext.Current.Server.MapPath("~/Template/1.xml"));but chart1 don't display fter click Reload button if it's loaded from Chart1.Serializer.Loa...

Easy explanation on Stateless management and State management
Hi,  Till now, me still confuse to understand Stateless management and State management. Can anybody explain to me in an easy understand with example? stateless - you cannot persist any values on frequent page request and response. state mgmt - you can retain values on subsequent calls. have a look at this"Never underestimate the power of stupid people in large groups" hi, The World Wide Web, on the other hand, is intrinsically stateless because each request for a new Web page is processed without any kn...

What is managed and un managed code in .net 2.0
Hi all what is the differnce between Managed and un Managed code in .net 2.0 can any body suggest me the article regarding use of Interfaces in .net 2.0   Best regards Rameezwaheedlife is name of learning!Mark as an answer if it helps Check out this link  Thanks,santosh_maharajaPlease mark as answer if you got expected solution.  Hi,    The code can be executed by .net CLR is Managed Code, code which can't be are unmanaged code Refer...Managed / UnManage...

Managing Users over .NET Management Website on different PCs
Hi,we are using Wed Developer Express 2005 on one PC to develop our website. The user and role management we are doing over the .NET website.No we hae installed Web Developer Express 2008 on another PC and also the other user should be able to manage the users and roles. But we always get a connection error to the Rsa provider.Can you please give me an idea what to do? Greetz, Chris  You dont tell us how you are running the site is it on a local iis or a hosted server and the same with the sql database? I take it that each machine has the website loaded in vwd and then you are u...

Using the Textbox.Text on Dynmaicly Created Textboxes in VB.Net
I found a script that i modified to create textbox fields Dynamicly.  I am now faced with the delimia of figuring out a way to pull the data in those dynamicly created fields.  Since they are not defined, I have not found a way to use a variable to pull the data. Here is the code .aspx   <%@ Page Language="VB" AutoEventWireup="false" CodeFile="DynamicTextboxes.aspx.vb" Inherits="DynamicTextboxes" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "

Web resources about - ViewState Remains as it is even if I explicitly false it in my textbox. -

List of scientific societies explicitly rejecting intelligent design - Wikipedia, the free encyclopedia ...
Q & A on Evolution and Intelligent Design: Is intelligent design a scientific alternative to contemporary evolutionary theory? No. Intelligent ...

Facebook News Feed Algorithm To De-Emphasize Stories From Apps Unless They Are Explicitly Shared
... stories from applications in News Feed , as Facebook announced a change to its News Feed algorithm that will emphasize what it calls explicitly ...

Christian Refugees Prioritised In An Explicitly Unchristian Way.
Debate over increased intake of Syrian Refugees has heated up with calls that any agreement to resettle those fleeing should include stipulations ...

Coalition amends terror laws to explicitly prohibit torture by security agents
NATIONAL security agents will be expressly prohibited from committing torture, after Senate crossbenchers threatened to withdraw support for ...

Torture will be explicitly prohibited in new counter-terrorism laws, Attorney-General George Brandis ...
New laws to bolster the powers of security agencies could face changes because of crossbench fears that the legislation allows suspects to be ...

Facebook News Feed Algorithm To De-Emphasize Stories From Apps Unless They Are Explicitly Shared
... stories from applications in News Feed , as Facebook announced a change to its News Feed algorithm that will emphasize what it calls explicitly ...

Rick Warren explicitly bans "unrepentant" gays from membership in his church
... us in his church. This is from the Saddleback Church's own Web site . You know things are bad when the church goes out of its way to explicitly ...

Android adware can install itself even when users explicitly reject it
(credit: Lookout) Two weeks ago, Ars reported on newly discovered Android adware that is virtually impossible to uninstall . Now, researchers ...

Fox News decries movie designed explicitly to sell toys as "anti-business"
Following the instructions on the back of their ideological boxes, Fox constructs another controversy.

China gay arrests 'explicitly linked' to Tiananmen anniversary
The BBC's John Sudworth says the arrest of gay activists is a sign of how sensitive the Chinese authorities are ahead of the anniversary of the ...

Resources last updated: 12/14/2015 11:59:30 AM