Querysring Example
http://www.dotnetfunda.com/post/PostAnswer.aspx?qid=1671&com=added
You can see in the above code that qid and com is the querystring. Querystring is appended at the last of URL of the web page and first querystring starts with ? and rest is appended with &
To get any of the querystring value use below code snippet
If (Request.QueryString["qid"] != null) // this will ensure that below line will only fire if querystring exists in the url
{
string qid = Request.QueryString["qid"];
}
ViewState Example:
ViewState is used to store the data in the form of hidden variable in the source code of the page.
<input type="hidden" name="hiddenId" id="hiddenID" value="25" />
To store the value in the ViewState you can use below code snippet
ViewState["hiddenId"] = "25";
To get the value of the ViewState, use below code
if (ViewState["hiddenId"] != null) // to ensure that the viewstate exists
{
string id = ViewState["hiddenid"].ToString();
}
Hope this will help.
Thank you
Regards,
Raja, USA
Suneel161, if this helps please login to Mark As Answer. | Alert Moderator