|
-
Sep 22nd, 2008, 09:56 PM
#1
Thread Starter
Fanatic Member
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.
-
Sep 23rd, 2008, 06:10 AM
#2
Fanatic Member
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.
-
Sep 24th, 2008, 04:06 AM
#3
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|