Hello All,
I have ASP.net , C# pages checking for query string variables, the old
ASP has a count property that one could check for each key/value pair to
determine if it is available in the query string or not, but ASP.net does
not have that for each key/value, instead there is a count for all items in
the query string.
Say if I have a query string variable called key1=value1 how do I check if
key1 was set or not?
Thanks a lot in advance.
Imran. 2 13018
I do it like this
if(Request.QueryString["key1"] != "" && Request.QueryString["key1"] != null)
{
//Querystring exists
}
And to make this less painful, i also create a static method that i call for
this.
So:
public class Common
{
public static bool HasValue(object o)
{
if (o == null)
{
return false;
}
if (o == System.DBNull.Value)
{
return false;
}
if (o is String)
{
if (((String) o).Trim() == String.Empty)
{
return false;
}
}
return true;
}
}
"Imran Aziz" <im***@tb2.net> wrote in message
news:eQ**************@TK2MSFTNGP14.phx.gbl... Hello All, I have ASP.net , C# pages checking for query string variables, the old ASP has a count property that one could check for each key/value pair to determine if it is available in the query string or not, but ASP.net does not have that for each key/value, instead there is a count for all items in the query string.
Say if I have a query string variable called key1=value1 how do I check if key1 was set or not? Thanks a lot in advance.
Imran.
Wonderful, thanks a lot Grant.
Imran
"Grant Merwitz" <gr***@workshare.com> wrote in message
news:uR**************@TK2MSFTNGP14.phx.gbl... I do it like this
if(Request.QueryString["key1"] != "" && Request.QueryString["key1"] != null) { //Querystring exists }
And to make this less painful, i also create a static method that i call for this.
So:
public class Common { public static bool HasValue(object o) { if (o == null) { return false; }
if (o == System.DBNull.Value) { return false; }
if (o is String) { if (((String) o).Trim() == String.Empty) { return false; } }
return true; } }
"Imran Aziz" <im***@tb2.net> wrote in message news:eQ**************@TK2MSFTNGP14.phx.gbl... Hello All, I have ASP.net , C# pages checking for query string variables, the old ASP has a count property that one could check for each key/value pair to determine if it is available in the query string or not, but ASP.net does not have that for each key/value, instead there is a count for all items in the query string.
Say if I have a query string variable called key1=value1 how do I check if key1 was set or not? Thanks a lot in advance.
Imran.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: NotGiven |
last post by:
In other words if I want to check if $SESSION = 'A',
do I also NEED to check isset($_SESSION) ?
If so, what logical IF statement works? I f have tried for an hour to come
up with a IF...
|
by: Bryan Russell |
last post by:
Hi,
I'm trying to pass the wildcard variable % to another page via
request.querystring.
When I go to pick up the variable through request.querystring, it will
never diplay the "%" if one is...
|
by: MikeR |
last post by:
Hello -
I pass an item to an asp page as a query string. The value has a space in it. On the
receiving page, the value displays fine just as a variable, but if I use it to pre-fill an
input box,...
|
by: Jim via DotNetMonster.com |
last post by:
Hi,
I'm passing a variable to another page through a querystring. I then want
to use that variable to retrieve records from a database to poulate a
dropdownlist. I can read the variable from the...
|
by: shapper |
last post by:
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
|
by: james |
last post by:
Hey Guys,
Do you have any idea how to acces Request.QueryString in a MasterPage?
I need to use it to modify my sitemap.
My code is:
public partial class MasterPage :...
|
by: Dieter Pelz |
last post by:
Hallo,
what is the best way to check the installation of mfc80 and vcrt sidebyside
assemblies?
Best Regards,
Dieter Pelz
|
by: bharathreddy |
last post by:
Here I will given an example on how to access the session, application and querystring variables in an .cs class file.
Using System.Web.HttpContext class.
1) For accesing session variables :...
|
by: Duggi |
last post by:
Hi
When does a static variable come into life? Well, as far as my
knowledge goes, I think it is during the execution of static
constructor. Because thats the logic point in the program where the...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |