querystring
How can we pass a querystring from an .asp page to aspx page?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
SenthilkumarPosted Feb 28, 2012, 9:34 AM
Query string to common to the any web technologies.
It is the behaviour of the web browser and you can redirect the correct url along with the query string. It can have only upto 0 to 255. If you send more than that then it will be restricted.
Suthish NairPosted Feb 9, 2012, 6:58 AM
test
Now on Page Load of test.aspx you can get the querystring information....
Satyapriya NayakPosted Feb 9, 2012, 6:51 AM
Consider the following URL:
http:// localhost/form.aspx?param1=abc¶m2=def
This html addresses use QueryString property to pass values between pages.
From the URL above the information obtained is:
form.aspx: which is the destination page for your browser.
Param1 is the first parameter, the value of which is set to abc
Param2 is the first parameter, the value of which is set to def
The '?' marks the beginning of the QueryString
'&' is used as a separator between parameters.
private void formButtonSubmit_Click(object sender, System.EventArgs e)
{
Response.Redirect("form.aspx?Param1=" +
this.formTextfieldParam1.Text + "&Param2=" +
this. formTextfieldParam2.Text);
}
The above code is a submit button event handler and it sends the values of the query string to the second page.
The following code demonstrates how to retrieve these valus on the second page:
private void Page_Load(object sender, System.EventArgs e)
{
this.form2TextField1.Text = Request.QueryString["Param1"];
this. form2TextField2.Text = Request.QueryString["Param2"];
}
You can also use the following method to retrieve the parameters in the string:
for (int i =0;i < Request.QueryString.Count;i++)
{
Response.Write(Request.QueryString[i]);
}
Thanks