viestate

Posted by Adnan under ASP.NET on 7/9/2009 | Views : 1667 | Status : [Member] | Replies : 7
how can we store hidden field value of any control into viewstate?




Responses

Posted by: Raja on: 7/9/2009 [Member] Starter

Up
0
Down
Write following code:

ViewState["ViewStateName"] = "Adnan";

or

ViewState["ViewStateName"] = txtHiddenField.Value;

or

ViewState["ViewStateName"] = txtBox1.Text;


Regards,
Raja, USA

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

Posted by: Rengan on: 7/9/2009 [Member] Starter

Up
0
Down
Hi friend,

ViewState["ViewStateVariableName"] = "rengan"; 

or
ViewState["ViewStateVariableName"] = hifHiddenField.Value;
i think this may help u




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

Posted by: Adnan on: 7/10/2009 [Member] Starter

Up
0
Down
thanku

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

Posted by: Adnan on: 7/10/2009 [Member] Starter

Up
0
Down
thanku

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

Posted by: Vuyiswamb on: 8/31/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Good Day Adnan

ViewStates are Expensive, rather use a Session and set it to null after you use it.

Thank you for posting at Dotnetfunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

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

Posted by: Lakhangarg on: 8/31/2009 [Member] [Moderator] Silver

Up
0
Down
Hi Vuyiswamb-

i am not agree with your answer. suppose i need to maintain values for the current page only in that case i think session variable will decrease the performance instead of viewstate.. Can you please explain how the Session variable are lighter than viewState Variables.
Tanks & Regards
Lakhan Pal Garg
http://lakhangarg.blogspot.com/



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

Posted by: Vuyiswamb on: 8/31/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Good Day

i would like to take a Chance to thank you for your involvement in Dotnetfunda. to answer your question.
Session State is useful for storing values that must be persisted across
multiple pages by the same user. ViewState is useful for storing
serializable data that must be persisisted across PostBacks by a single
page. If you use Session State, the value you insert will remain in memory
until (1) The Session times out, or (2) Your code removes it. If you use
ViewState, the value you insert will remain in ViewState until the user
requests a different page.

ViewStates are heavier than Sessions. look at this

http://forums.asp.net/p/1446151/3291440.aspx


Now the Problem with Viewstate is that it does not have the capability of expiration and means it will hog the memory until you close the page or move to another page.

Thank you for Posting at Dotnetfunda

Vuyiswa Maseko


Thank you for posting at Dotnetfunda
[Administrator]

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

Login to post response