How to validate an Ajax control combo box has item selected or not?

First, you need to insert beside the combo box a custom validator like this,

CustomValidatorSampleCode
If your combo box default selected value is an empty string then you need to add a function inside a script tag like this,

function CustomValidator(s, e) {
if ($find(s.controltovalidate)._textBoxControl.value == "") {
e.IsValid = false;
}
}

If your combo box default value of “Please select” then you need to add a function inside a script tag like this,

function CustomValidator(s, e) {
if ($find(s.controltovalidate)._textBoxControl.value == "Please select") {
e.IsValid = false;
}
}

References used:
Reference used

Advertisements
This entry was posted in Ajax Control, ASP.NET 4, ASP.NET 4 And Javascript. Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s