Querystring empty

  • Thread starter Thread starter tshad
  • Start date Start date
T

tshad

How do you check to see if there is no query string?

I could have:
1) file.aspx
2) file.aspx?r=5&st=joe

I need to know when there is no query string at all (1).

Thanks,

Tom
 
IF (Request.QueryString("yourQueryString") Is Nothing) Then

END IF

Or

if(Request.QueryString("yourQueryString") == null)
{

}

Cheers,
Adam
 
I don't understand.

I am not checking if there is a particular parameter there. I want to know
if the URL has 0 parameters (file.aspx). file.aspx?r=1 has 1 parameter and
file.aspx?r=1&st=joe has 2 parameters.

I want to be able to special processing if there is no parameters passed at
all. I don't want to check if r is nothing and st is nothing.

Thanks,

Tom
 
The c# version should be Request.QueryString["yourQueryString"].

if (Request.QueryString["yourValue"] == null) means that a parameter by
the name r does not exist, so there is not a parameter.

Check out this webpage. They take the items into a
NameValueCollection. Then if the collections count = 0, there are no
params.

HTH,
Darren Kopp
http://blog.secudocs.com/
 
I should have read the question..

Try:
If(Request.QueryString.Count = 0) Then

End If
 
I couldn't remember if QueryString had a count property or not.
Request.QueryString.Count is definately the road I would use too.

:D

Darren Kopp
 
Darren Kopp said:
The c# version should be Request.QueryString["yourQueryString"].

if (Request.QueryString["yourValue"] == null) means that a parameter by
the name r does not exist, so there is not a parameter.

No - that means there is no 'r' parameter. I have a page that could have
10-15 parameters and I don't want to check if each is null.

I want to check to see if there was no parameters at all passed (no "?").

Thanks,

Tom
 
Darren Kopp said:
I couldn't remember if QueryString had a count property or not.
Request.QueryString.Count is definately the road I would use too.

I had thought about that but wasn't sure if it had a count property. I was
thinking there might be something like Request.QueryString.Items.count or
something like that. But I think is what I am looking for.

Thanks,

Tom
 
Yea, I was the same, but i was without intellisense so I could only
give my first answer :s. Glad to hear you have found your solution
though.

Happy .NETing,
Darren Kopp
 

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