473,394 Members | 1,674 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Check if query string parameter exists

Hello,

How can I check if a parameter, for example "name", is available in a
QueryString?

I need to create a default value if the parameter is not available.

Thanks,

Miguel

Oct 7 '06 #1
2 72326
if (Request.QueryString["name"] == null)
{
// Default value
}

You may also use String.IsNullOrEmpty (Request.QueryString["name"]) to check
for both null and empty (name exists in the querystring but no value
specified) and give default value. String.IsNullOrEmpty is avaialble in .NET
2.0
"shapper" <md*****@gmail.comwrote in message
news:11*********************@i3g2000cwc.googlegrou ps.com...
Hello,

How can I check if a parameter, for example "name", is available in a
QueryString?

I need to create a default value if the parameter is not available.

Thanks,

Miguel

Oct 7 '06 #2
You test to see if it's null. For example, in c# you would do the following

string name = string.Empty;

if(Request.QueryString["name"] != null)
{
name = Request.QueryString["name"].ToString();
}

This creates a string called name, sets it to a default value (in this case
string.Empty), and if the querystring variable exists, set the string to
that variable.
--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"shapper" <md*****@gmail.comwrote in message
news:11*********************@i3g2000cwc.googlegrou ps.com...
Hello,

How can I check if a parameter, for example "name", is available in a
QueryString?

I need to create a default value if the parameter is not available.

Thanks,

Miguel

Oct 7 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: DottingTheNet | last post by:
i promise no more silly questions after this but how do i check if a table exists?? it is my understanding that the exists can only be used in the where clause of the query. i just want s'thing...
4
by: Corey | last post by:
All, I am relatively new to XML and I have what may sound like a dumb question. I want to pass a query string variable to my xml document and filter the output based on that variable. For...
3
by: D-Zyl | last post by:
I wanna execute a query with one parameter from MS VBA. the trouble is that the parameter is a control in a form. and I still don't know what is the code I need...
10
by: Onur Bozkurt | last post by:
I'am sending some data by the querystring. But I don't want it to be seen exactly because of security reasons. Is there a way to encrypt it and later decrypt when reading the querystring...? I...
1
by: johnpremi | last post by:
Hi there, I have to pass a query string parameter in my Web Config for loading a URL. We have two environments (production and devlopment) and MonitorURL needs to be changed when the deployment is...
4
by: keithb | last post by:
A page uses query string values to add a record to a database. The record should be added only once; however, if a user activates the url additional times, multiple records are added. Is there some...
5
by: ashurack | last post by:
I found a stored procedure online a while back and want to inplement it. The only problem is that it doesn't check to see if the number generated is currently in use in the DB. I know it's really...
2
by: qwedster | last post by:
Folk! How to programattically check if null value exists in database table (using stored procedure)? I know it's possble in the Query Analyzer (see last SQL query batch statements)? But how...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.