Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a question related to Request.QueryString:

I obtain a category name from URL with following format (i replaced URL name with codeproject.com for no advertising).

codeproject.com/default.aspx?category =asp.net

According to the incoming URL category name "asp.net" for example. I query SQL behind the code site.

My question is if i want to query 2 string from incoming URL; how can i do.

I mean:
- where to add second category name at codeproject.com/default.aspx?category =asp.net
- how to handle second category2 name with Request.QueryString at code site. I handle category string with following code:

C#
string catagory1="empty";
if(Request.QueryString["category"] !=null)
  {
     catagory1=Request.QueryString["catagory"].ToString();

  }


Kind Regards,
Posted
Updated 18-Dec-10 6:38am
v4

To put multiple parameters into a query string, use & to separate them:

For example

example.com/default.asps?animal=tiger&fruit=apple


To extract them, use

string myAnimal = Request.QueryString("animal")
string myFruit = Request.QueryString("fruit")
 
Share this answer
 
Comments
Sandeep Mewara 18-Dec-10 13:50pm    
Comment from OP:
It worked. Thank you Shepherd.
Actually here are two ways you can do that.

1. You can build a link with many variables like:
www.whatever.com/default.aspx?category1=A&category2=B&category3=C and so on

2. You can program your personal logic in one category name:
www.whatever.com/default.aspx?category=A|B|C
and after when you get a category value just parse it.

I hope it helps.
 
Share this answer
 
Comments
AAndrews 18-Dec-10 14:02pm    
yes it is a good idea.

You mean at code side to parse with recognizing layers with "|" which.

For example:
section menus link will be like:
database sql\ codeproject.com/default.aspx?catagory=1|sql|3|4|5
database sql\mssql\ codeproject.com/default.aspx?catagory=1|2|mssql|4|5
database sql\oracle\ codeproject.com/default.aspx?catagory=1|2|oracle|4|5

if i understand correct.

thank you fupslot
Fupslot 18-Dec-10 14:21pm    
yep.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900