In most of the cases developers need to pass more than one or multiple query string value from one page to another page. Here in this example i will show you how one can pass multiple values from one page to another page in an efficient way. Let I have a product row and want to send product data from one page to another page so the code will looks like:
01 | protected void Page_Load( object sender, EventArgs e) |
05 | string sName = "Tibbet" ; |
06 | string sBrand = "Kohinoor" ; |
07 | string sDescription = "For menz only" ; |
08 | Response.Redirect( string .Format( "Default.aspx?qs1={0}&qs2={1}&qs3={2}" , sName, sBrand, sDescription)); |
From second page we can read the value like:
01 | protected void Page_Load( object sender, EventArgs e) |
05 | if ((Request.QueryString[ "qs1" ] != null && Request.QueryString[ "qs2" ] != null ) && Request.QueryString[ "qs3" ] != null ) |
07 | string sName = Request.QueryString[ "qs1" ]; |
08 | string sBrand = Request.QueryString[ "qs2" ]; |
09 | string sDescription = Request.QueryString[ "qs3" ]; |
10 | Response.Write(sName+ "</br>" ); |
11 | Response.Write(sBrand + "</br>" ); |
12 | Response.Write(sDescription); |
No comments:
Post a Comment