Professional Web Applications Themes

Finding if a certain form elements exists... - ASP.NET General

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...

  1. #1

    Default Finding if a certain form elements exists...

    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 Guest

  2. #2

    Default Re: Finding if a certain form elements exists...

    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" <uk.com> wrote in message
    news:phx.gbl... 


    Marina Guest

  3. #3

    Default Re: Finding if a certain form elements exists...

    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" <uk.com> wrote in message
    news:phx.gbl... 


    Kevin Guest

  4. #4

    Default Re: Finding if a certain form elements exists...

    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" <com> wrote in message
    news:phx.gbl... [/ref]
    data. [/ref]
    of 
    >
    >[/ref]


    Stu Guest

  5. #5

    Default Re: Finding if a certain form elements exists...

    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" <uk.com> wrote in message
    news:eR%phx.gbl... 
    not [/ref]
    > data. [/ref][/ref]
    part 
    > >
    > >[/ref]
    >
    >[/ref]


    Kevin Guest

Similar Threads

  1. form elements generated dynamically from xml
    By endloop in forum Macromedia Flex General Discussion
    Replies: 1
    Last Post: April 29th, 11:01 AM
  2. generating form elements on the fly
    By Marc E in forum Macromedia Flex General Discussion
    Replies: 10
    Last Post: October 26th, 08:32 PM
  3. Add form elements into DB
    By G_Park in forum Macromedia ColdFusion
    Replies: 2
    Last Post: June 10th, 02:30 PM
  4. undefined form elements
    By SARAHBP in forum Macromedia ColdFusion
    Replies: 1
    Last Post: March 19th, 02:38 PM
  5. Replies: 0
    Last Post: June 29th, 02:17 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139