Thursday, April 15, 2010

Best way to pass multiple query string value from one page to another page with Response.Redirect method




Please visit my new Web Site https://coderstechzone.com



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:










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+"</br>");
                Response.Write(sBrand + "</br>");
                Response.Write(sDescription);
            }
        }
    }

Further Reading:
Ways to Pass data from one page to another page

0 comments:

Want to say something?
I WOULD BE DELIGHTED TO HEAR FROM YOU

Want To Search More?
Google Search on Internet
Subscribe RSS Subscribe RSS
Article Categories
  • Asp.net
  • Gridview
  • Javascript
  • AJAX
  • Sql server
  • XML
  • CSS
  • Free Web Site Templates
  • Free Desktop Wallpapers
  • TopOfBlogs
     
    Free ASP.NET articles,C#.NET,VB.NET tutorials and Examples,Ajax,SQL Server,Javascript,Jquery,XML,GridView Articles and code examples -- by Shawpnendu Bikash