Finding if a certain form elements exists...

Discussion in 'ASP .Net' started by Stu, Aug 18, 2003.

  1. Stu

    Stu Guest

    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



    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.510 / Virus Database: 307 - Release Date: 14/08/2003
     
    Stu, Aug 18, 2003
    #1
    1. Advertising

  2. Stu

    Marina Guest

    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

    "Stu" <> wrote in message
    news:...
    > 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
    >
    >
    >
    > ---
    > Outgoing mail is certified Virus Free.
    > Checked by AVG anti-virus system (http://www.grisoft.com).
    > Version: 6.0.510 / Virus Database: 307 - Release Date: 14/08/2003
    >
    >
     
    Marina, Aug 18, 2003
    #2
    1. Advertising

  3. Your problem could be in naming form fields with spaces in the names.

    --
    HTH,

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

    "Stu" <> wrote in message
    news:...
    > 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
    >
    >
    >
    > ---
    > Outgoing mail is certified Virus Free.
    > Checked by AVG anti-virus system (http://www.grisoft.com).
    > Version: 6.0.510 / Virus Database: 307 - Release Date: 14/08/2003
    >
    >
     
    Kevin Spencer, Aug 18, 2003
    #3
  4. Stu

    Stu Guest

    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 :)



    "Kevin Spencer" <> wrote in message
    news:...
    > Your problem could be in naming form fields with spaces in the names.
    >
    > --
    > HTH,
    >
    > Kevin Spencer
    > Microsoft MVP
    > .Net Developer
    > http://www.takempis.com
    > Neither a follower nor a lender be.
    >
    > "Stu" <> wrote in message
    > news:...
    > > 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
    > >
    > >
    > >
    > > ---
    > > Outgoing mail is certified Virus Free.
    > > Checked by AVG anti-virus system (http://www.grisoft.com).
    > > Version: 6.0.510 / Virus Database: 307 - Release Date: 14/08/2003
    > >
    > >

    >
    >
     
    Stu, Aug 19, 2003
    #4
  5. 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.

    "Stu" <> wrote in message
    news:eR%...
    > 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 :)
    >
    >
    >
    > "Kevin Spencer" <> wrote in message
    > news:...
    > > Your problem could be in naming form fields with spaces in the names.
    > >
    > > --
    > > HTH,
    > >
    > > Kevin Spencer
    > > Microsoft MVP
    > > .Net Developer
    > > http://www.takempis.com
    > > Neither a follower nor a lender be.
    > >
    > > "Stu" <> wrote in message
    > > news:...
    > > > 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
    > > >
    > > >
    > > >
    > > > ---
    > > > Outgoing mail is certified Virus Free.
    > > > Checked by AVG anti-virus system (http://www.grisoft.com).
    > > > Version: 6.0.510 / Virus Database: 307 - Release Date: 14/08/2003
    > > >
    > > >

    > >
    > >

    >
    >
     
    Kevin Spencer, Aug 19, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. KatB
    Replies:
    1
    Views:
    400
    Curt_C [MVP]
    Jan 7, 2004
  2. Replies:
    0
    Views:
    665
  3. Totan
    Replies:
    0
    Views:
    1,034
    Totan
    Apr 17, 2006
  4. Replies:
    2
    Views:
    537
    bruce barker
    Mar 25, 2008
  5. SAN CAZIANO
    Replies:
    8
    Views:
    187
    Dr John Stockton
    Oct 15, 2004
Loading...

Share This Page