Monday 25 March 2013

How to pass multiple values in querystring ?

Here's an example on how to pass Multiple querystrings in the page..
Page1
protected void Button1_Click(object sender, EventArgs e)
{
        string strName = "VINZ";
        string strAddress = "CEBU";
        string strDate = DateTime.Now.ToShortDateString();
        Response.Redirect(string.Format("TestNasad2.aspx?param1={0}&param2={1}&param3={2}",strName,strAddress,strDate));
}
The on Page2 you can get each values this way below
protected void Page_Load(object sender, EventArgs e)
{
        if ((Request.QueryString["param1"] != null && Request.QueryString["param2"] != null) && Request.QueryString["param3"] != null)
        {
            string name = Request.QueryString["param1"];
            string address = Request.QueryString["param2"];
            string date = Request.QueryString["param3"];

        }
}

0 comments:

Post a Comment


                                                            
 
Design by Abhinav Ranjan Sinha