CustomValidations does not fire

3 posts, 1 answers
  1. July
    July avatar
    205 posts
    Member since:
    Jul 2011

    Posted 15 Nov 2011 Link to this post

    This is my combobox with Custom validator
     <telerik:RadComboBox  ID="cbSecurityLevel" Skin="Vista" runat="server" ></telerik:RadComboBox>
                                       <asp:CustomValidator ControlToValidate="cbSecurityLevel" Display="Dynamic" CssClass="validator"
                                        OnServerValidate="cbSecurityLevel_ServerValidate" ID="cvSecurityLevel" runat="server"/>

    I fill dynamically :
       protected void Page_Load(object sender, EventArgs e)
            {

                if (Page.IsPostBack) return;

                LoadSettings();
                FillComboBox();           
            }

     private void FillComboBox()
            {
        cbSecurityLevel.EmptyMessage = _resources.GetString(cbSecurityLevel.ID, new CultureInfo(_culture));
                cbSecurityLevel.DataSource = _organization.GetSecurityLevels();
                cbSecurityLevel.DataTextField = "Name";
                cbSecurityLevel.DataValueField = "Id";
                cbSecurityLevel.DataBind();
            }


    This is Custom validator: (This does not Fire)
     protected void cbSecurityLevel_ServerValidate(object sender, ServerValidateEventArgs e)
            {
                e.IsValid = cbSecurityLevel.SelectedIndex > 0;
            }


    Thanks!
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 15 Nov 2011 Link to this post

    Hello Julieta,

    Make sure that you have set CausesValidation property of RadComboBox as true.

    -Shinu.
  3. July
    July avatar
    205 posts
    Member since:
    Jul 2011

    Posted 17 Nov 2011 Link to this post

    this not works :-(

    I changed CustomValidor by RequiredFieldValidator and Works!
    Thanks
Back to Top