Introduction:
In this article I will explain how to pass multiple parameters in query string or url in asp.net using C# and VB.NET.
In this article I will explain how to pass multiple parameters in query string or url in asp.net using C# and VB.NET.
Description:
In Previous posts I explained Send Gridview as Email Body, Dynamically display meta tags in asp.net, Differences between appsettings and connection strings and many articles relating to Asp.net, Gridview, SQL Server, Ajax, JavaScript etc. Now I will explain how to pass multiple parameters in url in asp.net using C# and VB.NET.
In Previous posts I explained Send Gridview as Email Body, Dynamically display meta tags in asp.net, Differences between appsettings and connection strings and many articles relating to Asp.net, Gridview, SQL Server, Ajax, JavaScript etc. Now I will explain how to pass multiple parameters in url in asp.net using C# and VB.NET.
If
we want to send one page control values to another page we can use QueryString concept.
If
we want to send multiple parameters from one page to another page we need to
write code like this
protected void
btnSend_Click(object sender, EventArgs e)
{
Response.Redirect("Default2.aspx?UserId="+txtUserId.Text+"&UserName="+txtUserName.Text);
}
|
Now
we need to get these values in another page (here I mentioned Default2.aspx) by
using QueryString Parameter values
with variable names or index values that would be like this
protected void
Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
lblUserId.Text = Request.QueryString["UserId"];
lblUserName.Text = Request.QueryString["UserName"];
}
}
|
Or
protected void
Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
lblUserId.Text = Request.QueryString[0];
lblUserName.Text = Request.QueryString[1];
}
}
|
If
you want to see complete example to pass multiple parameters in url check below
article
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. |
|||
|
|||
9 comments :
plz sir provide a tutorial on urlrewwriter.net
Nice One
PostBackUrl='<%# String.Format("~/Edit_Product.aspx?protype={0}&proname={1}&promeasure={2}&unitprice={3}&packsize={4}",Eval("pro_type"),Eval("pro_name"),Eval("pro_qty_measure"),Eval("pro_unit_price"),Eval("pro_pack_size"))%>'
can we pass class object as a parameter in querystring if any one knows reply
thanks by SM
Thanx..
could you please explain how to pass values to handler?
passing values from one page to another page....
using query string
please reply
good thank u
Note: Only a member of this blog may post a comment.