Hi
How can use QueryString in ASP.NET?
Loading
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.
Kunal NaikPosted Nov 17, 2011, 3:33 AM
Please have a look on below links for Query String in ASP.NET with example,
Link1
Link2
Prabhu RajaPosted Nov 17, 2011, 7:42 AM
Hope these Articles Will Help You.
http://www.c-sharpcorner.com/UploadFile/jalajakshi.venkataramana/StateManagementInWebForms11262005051214AM/StateManagementInWebForms.aspx
Satyapriya NayakPosted Nov 17, 2011, 2:50 AM
Please refer the below link
http://www.codeproject.com/KB/aspnet/QueryString.aspx
Thanks
TulasiPosted Nov 17, 2011, 2:25 AM
Disadvantage: it is visible to user , no security
passing values from current page to employeeinfo.aspx page
Ex: Response.Redirect("Employeeinfo.aspx?id=1001");
if u want o pass more than one values then use '&' to diffenrentiate
like Response.Redirect("Employeeinfo.aspx?id=1001&dept=10");
accessing Query string in Emploeeinfo.aspx (code behind)
Ex: int id=Convert.ToInt32(Request.QueryString["Number1"]);
Datta KharadPosted Nov 17, 2011, 12:26 AM
string number1 = Request.QueryString[0];
string number2 = Request.QueryString[1];
// The other way to Read the values
//string number1 = Request.QueryString["Number1"];
//string number2 = Request.QueryString["Number2"];
int result = Convert.ToInt32(number1) + Convert.ToInt32(number2);
Label2.Text = result.ToString();
AartiPosted Nov 17, 2011, 12:03 AM
What are Query Strings
Query strings are data that is appended to the end of a page URL.
They are commonly used to hold data like page numbers or search terms or other data that isn't confidential.
Unlike ViewState and hidden fields, the user can see the values which the query string holds without using special operations like View Source.
Query strings are included in bookmarks and in URLs that you pass in an e-mail.
They are the only way to save a page state when copying and pasting a URL.
The Query String Structure
query strings are appended to the end of a URL.
First a question mark is appended to the URL's end and then every parameter that we want to hold in the query string.
The parameters declare the parameter name followed by = symbol which followed by the data to hold.
Every parameter is separated with the ampersand symbol.
You should always use the HttpUtility.UrlEncode method on the data itself before appending it.
Query String Limitations
You can use query string technique when passing from one page to another but that is all.
If the first page need to pass non secure data to the other page it can build a URL with a query string and then redirect.
You should always keep in mind that a query string isn't secure and therefore always validate the data you received.
There are a few browser limitation when using query strings. For example, there are browsers that impose a length limitation
on the query string.
Another limitation is that query strings are passed only in HTTP GET command.
How To Use Query Strings
When you need to use a query string data you do it in the following way:
string queryStr = Request.QueryString["data"];
I hope it will help you.
Thanks.
karthik vPosted Nov 16, 2011, 4:38 PM
http://www.c-sharpcorner.com/uploadfile/dhananjaycoder/simple-explanation-for-very-beginners-of-query-string/