Solved

How does setting EnableViewstate to false really function ?

Posted on 2003-10-28
9
431 Views
Last Modified: 2012-08-13
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.
0
Comment
Question by:x666xchange
9 Comments
 
LVL 29

Expert Comment

by:David H.H.Lee
ID: 9635445
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"
0
 
LVL 4

Expert Comment

by:kblack15217
ID: 9635456
Try using EnableViewState="false".  Caps sensative.  Your understading of viewstate is correct
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9635487
In case this helps:

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


Caching issue?

Fritz the Blank
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:x666xchange
ID: 9671675
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.
0
 
LVL 29

Accepted Solution

by:
David H.H.Lee earned 500 total points
ID: 9676498
x666xchange,
It's  autocomplete ="off", if you set this property, your previous data wouldn't display again. However, if you prefer which control cant display the previous data, simply set this property inside the control.

<FORM Runat="server" autocomplete="off"> <---------All the control inside <Form> wouldn't display the history input

<Input Type="Text" id="txtInput" autoComplete="off"> <--reset history only for this control.

If autocomplete property not your main problems, let figure out the problems from EnableViewstate property.
For your info., EnableViewstate is set to True by default. To set it to false for all the page resist inside your project, just simply set in inside web.config. I think you have set it to true in someway, try to check again.

Regards
x_com
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11632571
to x_com?

FtB
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now