Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

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.

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.

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.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

6 comments :

safeer-ul-haq said...

plz sir provide a tutorial on urlrewwriter.net

Anonymous said...

Nice One

chandu kumar said...

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"))%>'

Prakash said...

Thank you

sravan said...

can we pass class object as a parameter in querystring if any one knows reply

Anonymous said...

thanks by SM

Give your Valuable Comments

Other Related Posts

© 2010-2012 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.