ARTICLE

QueryString property of Requet object in ASP.NET

Posted by Rohatash Kumar Articles | ASP.NET using VB.NET November 18, 2010
This article shows the QueryString in ASP.NET.
 
Reader Level:

This article shows the QueryString in ASP.NET.

Request object

Request object are used to carry data from client to server. To manage the data, Request provides QueryString collection.

QueryString collection:

passing variables content between pages ASP.NET gives us several choices. One choice is using QueryString property of Request Object.

For example:

Add the following code on the form load.

VB Code:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

       

        If Request.QueryString("num") IsNot Nothing Then

            Dim num As Integer = Integer.Parse(Request.QueryString("num"))

            For i As Integer = 1 To 10

                Response.Write(i * num & "<br>")

            Next

        End If

    End Sub

 

C# code

protected void Page_Load(object sender, EventArgs e)

        {  

            if (Request.QueryString["num"] != null)

            {

                int num=int.Parse(Request.QueryString["num"]);

                for (int i = 1; i <= 10; i++)

                    Response.Write(i * num+"<br>");

                   

            }

        }

 

Now save and run the application.

 

Data is send using ? sign in the address bar.


qs.gif 

Figure 1.

 

Now write the below URL address to the above window and than execute.


http://localhost:1641/WebForm6.aspx?num=12



qs1.gif

Figure 2.

Login to add your contents and source code to this article
share this article :
post comment
 
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Team Foundation Server Hosting
Become a Sponsor