Validating listbox

Rated 4.63/5 based on 562 customer reviews

I recently found out that the Required Field Validator works differently for a List Box than I needed; it checks to see if a row is selected, rather than checking to see if the listbox is empty.I tried using a Custom Validator but it does not seem to be firing (I have e.false in the validation function but still no intervention).You may want to go with the early-break out approach based on your prob desc & the fact that List Box.Selected Index will return -1 if nothing is selected.I have a required field validator for a list box, it validates and shows error where there is no entry in the list box, but when I add item to the list box, it still shows error.

When you add the items to the List Box, set the SELECTED property to true, and disable the List Box to avoid unselection.

In Asp.net, sometimes we need to validate List Box and Drop Down List using Required field validator.

It is tricky and avoids the use of Java Script function to validate List Box and Drop Down List. For validating Drop Down List, make sure you have "--Select--" option value 0 other wise validation on it will not work.

This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. By joining today you can post your own programming questions, respond to other developers questions, and eliminate the ads that are displayed to guests. Thanks mtranchi, Its working fine but I need one more help please.

How, I can run macro automatically when value is changed in Validation listbox, and also it should display entire records when ALL is selected from the listbox. Aaloki should say though that it sounds like you maybe reinventing the wheel.

Leave a Reply