Link to home
Start Free TrialLog in
Avatar of x666xchange
x666xchange

asked on

How does setting EnableViewstate to false really function ?

I have created a simple web application using Visual Studio.NET as follows :

<%@ Page Language="VB" EnableViewstate="false" %>
<HTML>
   <BODY>
      <FORM Runat="server">
         Enter Your Name : <asp:textbox Id = "tbxMessage" Runat="server"/>
         <asp:button Id="btnSubmit" Text="Submit" Runat="server"/>      
      </FORM>
   </BODY>
</HTML>

I believe after submitting the page with some text in the text box the page should be re-displayed with the textbox being empty in the manner that a traditional asp page works, since I've set the EnableViewstate attribute to "false".

However, when I've found after submitting the page, that it re-displays the text that was input into the text box after it returns.
When I checked the source of the returned page, it did display a ViewState hidden element in it.

I was trying to understand how exactly "viewstate" works by creating a simple page. Is my understanding of the viewstate as mentioned in the para immediately above incorrect ? What am I missing. Kindly guide me.
Avatar of David H.H.Lee
David H.H.Lee
Flag of Malaysia image

x666xchange,
It would erase you history. You may try this as well :
 <FORM Runat="server" autocomplete="off">
        Enter Your Name : <asp:textbox Id = "tbxMessage" Runat="server"/>
        <asp:button Id="btnSubmit" Text="Submit" Runat="server"/>      
     </FORM>

-set the property for autocomplete="false"
Avatar of kblack15217
kblack15217

Try using EnableViewState="false".  Caps sensative.  Your understading of viewstate is correct
In case this helps:

http://www.w3schools.com/aspnet/aspnet_viewstate.asp


Caching issue?

Fritz the Blank
Avatar of x666xchange

ASKER

I have tried setting autocomplete to "false" aswell as "off" for the form. Even tried setting the AUTOCOMPLETE feature directly in IE to unchecked.

None of the above worked. Any other suggestions please. Just can't figure out what's going wrong.
ASKER CERTIFIED SOLUTION
Avatar of David H.H.Lee
David H.H.Lee
Flag of Malaysia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
to x_com?

FtB