view state data store

Posted by Bhuwan87rawat under ASP.NET on 8/24/2012 | Points: 10 | Views : 1104 | Status : [Member] | Replies : 2
Hi.
In my application i want to store only username store in a textbox in page load with the help of view state....
this possible ....



regard
Bhuwan




Responses

Posted by: Ranjeet_8 on: 8/24/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
can u plz clearly define ur problem what u want ???

u can use View State or Session to store username.

ViewState persist the values of controls of particular page in the client (browser) when post back operation done. When user requests another page previous page data no longer available.

ViewState["ViewstateName"]="UserName"; // Store
TextBox1.Text=ViewState["ViewstateName"].ToString(); //Retrieve


SessionState persist the data of particular user in the server. This data available till user close the browser or session time completes.

Session["SessionName"]="UserName"; //Store
TextBox1.Text=Session["SessionName"].ToString(); // Retrieve



Bhuwan87rawat, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rambabu123 on: 8/25/2012 [Member] Starter | Points: 25

Up
0
Down
//userName Store into viewstate;
if(UserName.Text!="")
{
ViewState["ViewstateName"]=UserName.Text;
}
//Retrive Data From viewstate;
string UName=ViewState["ViewstateName"].Tostring();


Bhuwan87rawat, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response