Finding if a certain form elements exists...

  • Thread starter Thread starter Stu
  • Start date Start date
S

Stu

Hi,

I want to be able to check if a form element exists in the form post data.
IN this instance I want to find out if Request.Form("Postcode") is part of
the forms collection.

I have tried:

If Request.Form("Address Line 5").Length > 0 Then Response.Write("It
exists!")

but get the error:
Object reference not set to an instance of an object.

Thanks in advance,

Stu
 
The problem here is, that it doesn't exist - but you are trying to get the
Length property of an object that doesn't exist

Try: If Request.Form("Address Line 5") <> "" Then

OR

If Not IsNothing(Request.Form("Address Line 5") ) Then
 
Many thanks.

The 'If Not IsNothing(Request.Form("Address Line 5") ) Then' worked great.

Kevin > I had tried both with and without the spaces in the form name and
the spaces don't alter the functionality. I know spaces in form names is not
good practice, but the form is built by an end user using a WYSIWYG edtor
and could be called anything...I'm almost surprised that they stopped at
spaces :-)
 
Make sure it works in all browsers, unless you're developing specifically
for IE. Chances are, it won't.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Neither a follower nor a lender be.
 
Back
Top