.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

ViewState Details

Posted By: venu     Posted Date: July 04, 2011    Points:5   Category :ASP.Net
Hi Friends!

What is the use of viewstate?what happends if enableVeiwstate=false for a control or a page.


Thanks & Regards
----------------
Venu

Responses
Author: Gowthammanju             
Posted Date: July 05, 2011     Points: 20   

An approach to saving data for the user, is the ViewState.

The ViewState allows ASP.NET to repopulate form fields on each postback to the server, making sure that a form is not automatically cleared when the user hits the submit button.

Thanks & Regards,
GowthamManju
Chennai



Mark if the answer is true
Author: Gowthammanju             
Posted Date: July 05, 2011     Points: 20   

Coding as


in page load event

 if(ViewState["NameOfUser"] != null)
Label.Text = ViewState["User"].ToString();
else
Label.Text = "Not set yet...";


in submit button click event


ViewState["User"] = NameField.Text;
Label.Text = NameField.Text;


Thanks & Regards,
GowthamManju
Chennai



Mark if the answer is true
Author: Dhiraj Ranka             
Posted Date: July 05, 2011     Points: 20   

This is a complete guide for ASP.NET ViewState

http://msdn.microsoft.com/en-us/library/ms972976.aspx

Hope this helps

Hope this helps.

Thanks & Regards,
Dhiraj Ranka
http://www.twitter.com/dhirajranka | http://www.dhirajranka.com
Author: Ravi Ranjan Kumar             
Posted Date: July 09, 2011     Points: 20   

View state is a repository in an ASP.NET page that can store values that have to be retained during postback. The page framework uses view state to persist control settings between postbacks.

if you have set EnableViewState = false at Page level then it doesn't matter whether EnalbleViewState = true for any control. It will not maintain the ViewState for the controls which resides on Page.

If you have set EnableViewState = true at Page level and for any controls, if you have set EnableViewState = true then for that controls only ViewState will be maintained. For other controls it will not maintain.

Reference Links :-
http://msdn.microsoft.com/en-us/library/bb386448.aspx
http://www.eggheadcafe.com/community/aspnet/17/10234113/enableviewstate-of-page-is-false-nd-enableviewstate-of-control-is-true.aspx

Thanks & Regards
Ravi Ranjan Kumar
http://raviranjankr.wordpress.com


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend