Tuesday 2 February 2010

QueryString passing in code behind

In Default.aspx:

<a href="Default.aspx?ThisVar=1">Click here</a>

In Default.aspx.cs:

string ThisVariable = string.Empty;
TestProductLable.Text = "Photos";

if (Request.QueryString["ThisVar"] != null && Request.QueryString["ThisVar"] != "")
{
ThisVariable = Request.QueryString["ThisVar"].ToString();
Response.Write(ThisVariable);
}
else
{
Response.Write("No click yet");
}

No comments:

Post a Comment