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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Feb 9, 2012, 1:51 AM EST
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
Suthish NairRank #92 · 22.8K reputationPosted Feb 9, 2012, 1:58 AM EST
test
Now on Page Load of test.aspx you can get the querystring information....
SenthilkumarRank #387 · 6.5K reputationPosted Feb 28, 2012, 4:34 AM EST
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.