alert('Oh shit !!!! Javascript is disabled!!!! ');


Blog Archive

Query String In ASP.NET

Query String In ASP.NET

Query string is used to Pass the values or information form one page to another page.

The query string  is a holdover from the ASP days of web programming. You will see this a lot when you are surfing around the internet. Basically, it is passing information to the next page with the URL .You can use a query string to submit data back to your page or to another page through the URL. Query strings provide a simple but limited way of maintaining some state information.

The advantages of using query strings are

  • No server resources required. The query string is contained in the HTTP request for a specific URL.
  • Broad support. Almost all browsers and client devices support passing values in a query string
  • it is very easy

The disadvantages of using query strings are

  • Security. The information in the query string is directly visible to the user via the browser user interface. The query values are exposed to the Internet via the URL so in some cases security may be an issue. 
  • Limited capacity. Most browsers and client devices impose a 255-character limit on URL length

.CS CODE


 private void btnSubmit_Click(object sender, System.EventArgs e)
{
Response.Redirect("Default.aspx?Name=" +
this.txtName.Text + "&LastName=" +
this.txtLastName.Text);
} 

Our first code part builds a query string for your application and send contents of your textboxes to second page. Now how to retrieve this values from second page.

Put this code to second page page_load.

.ASPX CODE


private void Page_Load(object sender, System.EventArgs e)
{
this.txtBox1.Text = Request.QueryString["Name"];
this.txtBox2.Text = Request.QueryString["LastName"];
}