In this article I will explain how to create QueryString example in asp.net using C# and VB.NET.
In Previous posts I explained Dynamically display meta tags in asp.net, Differences between appsettings and connection strings, jQuery get hidden field values from asp.net gridview and many articles regarding Asp.net, Gridview, SQL Server, Ajax, JavaScript etc. Now I will explain how to create QueryString example in asp.net using C# and VB.NET.
protected void
btnSend_Click(object sender, EventArgs e)
{
Response.Redirect("Default2.aspx?UserId="+txtUserId.Text);
}
|
protected void
btnSend_Click(object sender, EventArgs e)
{
Response.Redirect("Default2.aspx?UserId="+txtUserId.Text+"&UserName="+txtUserName.Text);
}
|
protected void
Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
lblUserId.Text = Request.QueryString["UserId"];
lblUserName.Text = Request.QueryString["UserName"];
}
}
|
protected void
Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
lblUserId.Text = Request.QueryString[0];
lblUserName.Text = Request.QueryString[1];
}
}
|
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>QueryString Example in asp.net</title>
</head>
<body>
<form id="form1"
runat="server">
<div><b>QueryString Example</b></div><br />
<div>
<table>
<tr>
<td><b>UserId:</b></td>
<td><asp:TextBox ID="txtUserId"
runat="server"/></td>
</tr>
<tr>
<td><b>UserName:</b></td>
<td><asp:TextBox ID="txtUserName"
runat="server"/></td>
</tr>
<tr>
<td></td>
<td><asp:Button ID="btnSend"
Text="Send
Values" runat="server" onclick="btnSend_Click"/></td>
</tr>
</table>
</div>
</form>
</body>
</html>
|
protected void
btnSend_Click(object sender, EventArgs e)
{
Response.Redirect("Default2.aspx?UserId="+txtUserId.Text+"&UserName="+txtUserName.Text);
}
|
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1"
runat="server">
<title>QueryString Example in asp.net</title>
</head>
<body>
<form id="form1"
runat="server">
<div><b>QueryString parameter Values in Default2.aspx Page</b></div><br />
<div><b>UserId:</b><asp:Label ID="lblUserId" runat="server"/></div><br />
<div><b>UserName:</b><asp:Label ID="lblUserName" runat="server"/></div>
</form>
</body>
</html>
|
protected void
Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
lblUserId.Text = Request.QueryString["UserId"];
lblUserName.Text = Request.QueryString["UserName"];
}
}
|
|
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
Subscribe by RSS
Subscribe by Email
|
|||
|
|

Subscribe by RSS
Subscribe by Email
13 comments :
Thank you. Excellent .
very very useful link...
nice helping alot......
nice but i want to display the checkboxlist when we click on the button on same page.
sir plz make urlrewriting for the query string.
i want to look this url default2.aspx/suresh-dasari
default2/suresh-dasari plz provide some urlrewriter.net article
Great article....really helpful
good
thanks Sir but 1 question in my mind
How can i open popupwindow using Response.redirect().
thanks......... it has been very helpful...
Where are the VB code sample...?
' VB Code Sample
Protected Sub btnSend_Click(sender As Object, e As EventArgs)
Response.Redirect("Default2.aspx?UserId=" + txtUserId.Text)
End Sub
' or
Protected Sub btnSend_Click(sender As Object, e As EventArgs)
Response.Redirect("Default2.aspx?UserId=" + txtUserId.Text + "&UserName=" + txtUserName.Text)
End Sub
Protected Sub Page_Load(sender As Object, e As EventArgs)
If Not IsPostBack Then
lblUserId.Text = Request.QueryString("UserId")
lblUserName.Text = Request.QueryString("UserName")
End If
End Sub
thanks sir it is useful for me. But i want to send that details to my mail. how can i send. please help me out
teri bhes ki aakh