Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_professional thread: Null Values in C#


Message #1 by "Chris Bond" <chris@l...> on Thu, 2 Aug 2001 10:34:38 +0100
Cheers really don't know why I didn't try that I was searching for a
class!!

> -----Original Message-----
> From: Mitch Denny [mailto:mitch.denny@w...]
> Sent: 02 August 2001 12:37
> To: ASPX_Professional
> Subject: [aspx_professional] RE: Null Values in C#
> 
> Chris,
> 
> Not a problem, check the existence like this:
> 
> 	if (this.Request.QueryString["gid"] != null) {
> 
> 		// Your code here.
> 
> 	}
> 
> Hope this helps.
> 
> ----------------------------------------
> 
> > -----Original Message-----
> > From: Chris Bond [mailto:chris@l...]
> > Sent: Thursday, 2 August 2001 7:35 PM
> > To: ASPX_Professional
> > Subject: [aspx_professional] Null Values in C#
> >
> >
> > Hi,
> >
> > Im trying to doing the following statement in C# in ASP.NET:
> >
> > if (Request.QueryString["gid"].Length >0)
> > {
> > 	Session["CurrentGroup"] = Request.QueryString["gid"];
> > }
> > else
> > {
> > 	Session["CurrentGroup"] = 1;
> > }
> >
> > Request.QueryString["gid"] is not being passed to the current
> > page only if the user clicks on a hyperlink on the page it will be passed.
> >
> > The code aboves generates a System.NullReferenceException: Value null
> > was found where an instance of an object was required.
> >
> > Does anybody know the correct syntax to check if the
> > QueryString["gid"] exists without generating a null exception?
> >
> > Kind Regards,
> > Chris Bond


  Return to Index