Dropdownlist and requiredfieldvalidator postback problem

A

anandv81

Hi,

I have a dropdownlist and a requiredfieldvalidator that checks if a
value has been selected for the dropdownlist by the user. I am
populating the ddl at runtime and adding two items ( "Please select"
and "All") the "Please select" option has a value of "".

The problem I am facing is that when I select the "Please select"
option the error message of the requiredfield validator gets displayed
for a second or so and then the page posts back. I wanted that the
error message should be displayed and the page shouldnt post back, am I
doing something wrong here?. I could check the value of the selected
item at the server side but thats just a waste of one round trip. The
autopostback property of the dropdownlist is set to true. Any help
would be appreciated . Thanks in advance.

Regards

Andy
 
G

Guest

Hi anand
Try setting "please select" item values to "-1" and in requiredfield
validator give initial value as -1.
Let me know if this doesn't solve.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top