Asp.Net – what is query string in asp.net with example

Querystring is a kind of variable which can be used to pass a value from one page to another page. hence there are several way to pass value from one page to another page. but we are describing on this article.

Querystring variable pass with variable with “?”

For example: http://www.abc.com/test.html?var1=this is query string variable value.

In the above example “var1” is variable name and “this is query string variable value.” the variable value. we can use this querystring in asp.net as follows.

string var1=Request.QueryString[“var1”];

We can use mutliple querystring variable as well. first variable would use with “?” and other variable will use with “&”

For example: http://www.abc.com/test.html?var1=this is first variable&var2=this is second variable&var3=this is third variable

In the above example “var1”, “var2” and “var3” are querystring variable and we can fetch the values of query string value in asp.net as follows.

string var1=Request.QueryString[“var1”];
string var2=Request.QueryString[“var2”];
string var3=Request.QueryString[“var3”];

Share this:
Share