Friday, June 24, 2011

querystring

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string sName = "Tibbet";
string sBrand = "Kohinoor";
string sDescription = "For menz only";
Response.Redirect(string.Format("Default.aspx?qs1={0}&qs2={1}&qs3={2}", sName, sBrand, sDescription));
}
}

From second page we can read the value like:

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if ((Request.QueryString["qs1"] != null && Request.QueryString["qs2"] != null) && Request.QueryString["qs3"] != null)
{
string sName = Request.QueryString["qs1"];
string sBrand = Request.QueryString["qs2"];
string sDescription = Request.QueryString["qs3"];
Response.Write(sName+"");
Response.Write(sBrand + "");
Response.Write(sDescription);
}
}
}

No comments:

Post a Comment