about request.querystring.

  • Thread starter Thread starter Arvan
  • Start date Start date
A

Arvan

there is 3 links to page default.aspx,and each one has a querystring,like
a=1, b=1 ,c=1.

problem is how do i ensure the name of querystring!

how do?
 
I quess u want to know which query string has come and from which page u
have been redirected
one way to know from which page u have been redirected is
Request.UrlReferrer.AbsolutePath;



otherwise

u can check values are not null like this

if((Request.QueryString["a"]!="")&&(Request.QueryString["a"]!=null)

{

string x=Request.QueryString["a"]

}
 
I am sorry.Well,i mean i have 3 pairs name/value collection.For example, at
default aspx page, i redirect to catalog.aspx?cataid=3 and at other code of
default.aspx redirect to catalog.aspx?catamr=1 .Right now how do i ensure
the name of querystring "cataid" or "catamr" at catalog.aspx.

if i can ensure the same , it could do something.

switch(.....)
case "cataid":
//do something about cataid
break;
case "catamr":
//do something about catamr
break;
 
Get the value of any querystring that you handle in the code:

string cataId, cataMr;
cataId = Request.QueryString["cataid"];
cataMr = Request.QueryString["catamr"];

Then check if the strings contain a value or not:

if (cataId != null) {
// handle cataid
}
if (cataMr != null) {
// handle catamr
}

or if they should be exclusive:

if (cataId != null) {
// handle cataid
} else if (cataMr != null) {
// handle catamr
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top