Results 1 to 3 of 3

Thread: requiredvalidator on listbox: validating whether the listbox has items or not

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    589

    requiredvalidator on listbox: validating whether the listbox has items or not

    I think a requiredvalidator applied to a listbox validates whether the listbaox has an iemselected or not, meaning that if I have items on my listbox but none is selected then the validation fails.

    Instead of that, I want to implement The following behaviour :

    If the listbox contains items then I want the validation to pass but if it has no items, I want the validation to fail.

    Any suggestion pls?

    Thank thee
    Thanks a lot for your help.

  2. #2
    Fanatic Member
    Join Date
    Feb 2006
    Posts
    592

    Re: requiredvalidator on listbox: validating whether the listbox has items or not

    Hi tutus,

    Maybe I'm missing something but, the number of items in a listbox is
    not something the user can change (unless you have written some extra code for that).
    Therefore, it's not supposed to be validated.

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: requiredvalidator on listbox: validating whether the listbox has items or not

    But it can be manipulated using javascript from elsewhere on the page.

    Use a custom validator. The custom validator allows for both client side scripts and server side scripts. I suggest you write both.

    In the client side script (javascript) you can check for

    document.getElementById('the DDL ID').options.length > 0

    In the server side code, you simply do an Items.Count.

Posting Permissions

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



Click Here to Expand Forum to Full Width