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

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

Author: Zunnair
Download Source Code :

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
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"]);
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
protected void Button1_Click(object sender, EventArgs e)
            Server.Transfer("default.aspx?queryvalue=" + TextBox1.Text);
        catch (Exception ex)
            Label3.Text = ex.Message;
 Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
            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 2.0.
Add Article Comment:
Name :
Email Address :
Comments :
<< Upload image to ftp with file uploader using 2.0.

Disclaimer - Privacy
© 2002-2017