Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

Sending and getting value of query string in same page using asp.net 2.0.

Author: Zunnair
Download Source Code : 901_querystring.zip

In this simple article you will learn to working with query string.

 

Create a web application in c#
Drag a button, three labels and one textbox on the form
Then write code on form load event
 
C#
protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Label1.Text = "Query string value";
            TextBox1.Text = "Devasp Query string";
            Button1.Text = "Post Query string";
            Label2.Text = "Query string Value";
            Label3.Text = "No Value";
        }
        Label3.Text = Convert.ToString(Request.QueryString["queryvalue"]);
    }
VB
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        If Not IsPostBack Then
            Label1.Text = "Query string value"
            TextBox1.Text = "Devasp Query string"
            Button1.Text = "Post Query string"
            Label2.Text = "Query string Value"
            Label3.Text = "No Value"
        End If
        Label3.Text = Convert.ToString(Request.QueryString("queryvalue"))
    End Sub
After that write some code on button click even
C#
protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            Server.Transfer("default.aspx?queryvalue=" + TextBox1.Text);
        }
        catch (Exception ex)
        {
            Label3.Text = ex.Message;
        }
VB
 Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
        Try
            Server.Transfer("default.aspx?queryvalue=" & TextBox1.Text)
        Catch ex As Exception
            Label3.Text = ex.Message
        End Try
    End Sub
 
This is simple code to working with query string in asp.net 2.0.
 
   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Upload image to ftp with file uploader using asp.net 2.0.

Disclaimer - Privacy
© 2002-2017 DevASP.net