Solved

How can I check parameter or session collection for a key?

Posted on 2003-10-27
2
219 Views
Last Modified: 2010-04-16
How can I check if a parameter exists in the parameter collection or a key exists in
the Session collection?  

Currently I get an error when I do this and when there is no parameter
passed to the page: Request.Params["DBType"].

Samething I get when I do this with the Session object.

The error I get is this:
System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 97:             private void Page_Load(object sender, System.EventArgs e)
Line 98:             {
Line 99:                   if(Request.QueryString["DSNType"].ToString() != "")
Line 100:                  {
Line 101:                              Response.Write("yes");
 
Thanks,

Andrzej
0
Comment
Question by:andw928
  • 2
2 Comments
 
LVL 10

Accepted Solution

by:
smegghead earned 50 total points
ID: 9628210
put something like..

object MyObj=Request.QueryString["DSNType"];
if (MyObj!=null)
{
    Response.Write("yes");
}
0
 
LVL 10

Expert Comment

by:smegghead
ID: 9628861
blimey, what do I have to do for an 'a' ?? do you want a tip ?

0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question