»Dotnet Ads
»Message Boards
Message Boards
Dotnet Books
»Member Details
Register
Login
LogOut
Submit Code
Submit Jobs
Submit Projects
»Competition
Community
Winners
Prizes
Write For Us
Members
»Other Resources
Links
Dotnet Resources
|
Required Field Validator For CheckBoxListusing System;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Validators {
public class RequiredFieldValidatorForCheckBoxList: BaseValidator {
protected override bool ControlPropertiesValid(){
return true;
}
protected override bool EvaluateIsValid() {
return this.EvaluateIsChecked();
}
protected bool EvaluateIsChecked() {
CheckBoxList _cbl = ( ( CheckBoxList ) this.FindControl( this . ControlToValidate ) );
foreach( ListItem li in _cbl.Items ) {
if ( li.Selected == true ) {
return true;
}
}
return false;
}
protected override void OnPreRender( EventArgs e ){
if ( this.EnableClientScript ) { this.ClientScript(); }
base.OnPreRender( e );
}
protected void ClientScript() {
this.Attributes["evaluationfunction"] = "cb_vefify";
StringBuilder sb_Script = new StringBuilder();
sb_Script.Append( "
© 2008 dotnetwatch.com -- Privacy policy
|
|