Hi friends,
I want to know about the query string and how does it work.
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.
V S N Raju KanumuriPosted May 9, 2012, 1:29 AM
Query string is used to Pass the values or information form one page to another page.
For example in first page you collect information about your client, her name and use this information in your second page. So you need query string to pass name from one page to another page.
Pass QueryString variable to another page
www.exmaple.com?id=1
here id is a Querystring variable
Retrieve Query String as follow
Request.QueryString["id"]
SenthilkumarPosted May 8, 2012, 11:28 PM
The query string is client side state mechanism which is used to pass the values between the pages with in the same domain or other domain.
It will be the part of client browser url and has the limit to pass the values in the query string. It can have the maximum of 255 characters.
The portion of a dynamic URL that contains the search parameters when a dynamic Web site is searched. Query strings do not exist until a user plugs the variables into a database search, at which point the search engine will create the dynamic URL with the query string based on the results. Query strings typically contain ? and % characters. The following URL is an example of a dynamic URL with a query string as the result of a search in the Webopedia database for the term "query string.
For example,
when click on any button you can redirect to the page with query string.
Response.Redirect("sample.aspx?ID=110&Name=senthil");
In client side,
window.location.href='sample.aspx?ID=110&Name=senthil';
The query string value in the redirected page can be accessed in the client side script or server side code as well.
Refer this tutorial for query string in asp.net page,
http://www.dotnetperls.com/querystring
Satyapriya NayakPosted May 8, 2012, 12:30 PM
Query string is used to Pass the values or information form one page to another page.
Syntax
Request.QueryString(variable)[(index)|.Count]
Parameters
variable :-
Specifies the name of the variable in the http query string to retrieve.
index :-
An optional parameter that enables you to retrieve one of multiple values for variable. It can be any integer value in the range 1 to Request.QueryString(variable).Count.
For exapmle:-
In page 1:
Drag and drop the one textbox and button control
In page 2:
Drag and drop the one textbox control from tool box and place it on form.
In page one:-
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
'bind the textbox values to querystring
Response.Redirect("Default2.aspx?Textboxvalue=" & TextBox1.Text)
End Sub
End Class
In page two:-
Partial Class Default2
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Get the values from Query string
TextBox1.Text = Request.QueryString("Textboxvalue")
End Sub
End Class
Thanks