Sunday, 16 September 2012

PASSING AND RETRIEVING VALUES USING QUERY STRING IN ASP.NET

 Pass and Retrieve the values using QUERY STRING in any event :

For example:

          In this I use a Button event for passing the values

         protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("nextpage.aspx?name=" + TextBox1.Text +      "&age=" + TextBox2.Text );

      // The question mark "?" denotes the query string

    }

        Retrieving the passed values from the first page in  second page during the load event

       protected void Page_Load(object sender, EventArgs e)
    {

        Label1.Text = "Hi Welcome " + Request.QueryString["name"];
        TextBox1.Text = Request.QueryString["pass"];

    }
   

No comments:

Post a Comment

back to top