public knowledge blog_load(sender Virendra)

                                                                                                                          Nothing shocks me, I am a Software Engineer.

Text Box and EnableViewState set to false.

Posted by Virendra Dugar on January 7, 2009

Before some days I was just exploring that How EnableviewState works. I noticed one thing that EnableViewState is not working with the textbox. I tried this example

I put a text box with EnableViewState= “false” and a button on the page.

<asp:textbox id=”TextBox1″ enableviewstate=”False” runat=”server”/>
<asp:button id=”Button1″ onclick=”Button1_Click” runat=”server” text=”Button”/>

I entered some value in the text box and When I clicked on the button, the page got refreshed but the text box was maintaining its value.
It was a bit weird thing for me.

After hours of hard work, I came to know this.“Textboxes do not use ViewState to maintain their values across postbacks.These controls simply post their values as normal to the server and then the server simply takes that value and makes it be the default value of the new control generated for the postback. You can see this if you view the source code of the page after the initial form submission, the textbox will have a ‘value’ attribute set to the data entered into the textbox when it was submitted.”

For more information on this, check out these links..
Microsoft Link
Joteke’s Blog

Enjoy..

Advertisements

2 Responses to “Text Box and EnableViewState set to false.”

  1. Perfy said

    I have this problem too. How could I solve it?

  2. Hi Prefy,
    Thanks. But what is your exact problem? can you explain me in details?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: