QueryString property of Requet object in ASP.NET using VB.NET

This article shows the QueryString in ASP.NET.
  • 1626

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.

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.