Load-On-Demand RadComboBox does not raise CustomValidator.ServerValidate when blank

3 posts, 0 answers
  1. Wyatt
    Wyatt avatar
    31 posts
    Member since:
    Aug 2009

    Posted 27 May 2010 Link to this post

    Following this documentation, I am requiring that a value be set in a Load-On-Demand RadComboBox.  Both the client and server validation events are raised when text has been entered.  If there is no text, neither the client nor the server validation events are raised.  Also of note, MarkFirstMatch = True, ShowMoreResultsBox = True, and EnableVirtualScrolling = True.

    I was able to fix this problem by adding a RequiredFieldValidator in addition to the CustomValidation.  Is this by design?
  2. Kalina
    Kalina avatar
    918 posts

    Posted 02 Jun 2010 Link to this post

    Hello Wyatt,

    You can use the CustomValidator control to validate the RadComboBox upon value and at the same time - to validate if the RadComboBox input is empty. 

    Here is one basic sample to illustrate the approach:
    <telerik:RadComboBox ID="RadComboBox1"  AllowCustomText="true"
    <asp:Button ID="btnTSubmit" runat="server"
        CausesValidation="true" Text="Submit" />
    <asp:CustomValidator ID="CustomValidator1" runat="server"
        ErrorMessage="You must select an item with even value"
    <script type="text/javascript">
        function validateCombo(source, args) {
            args.IsValid = false;
            var combo = $find("<%= RadComboBox1.ClientID %>");
            var text = combo.get_text();
            if (text.length < 1) {
                args.IsValid = false;
            else {
                var node = combo.findItemByText(text);
                if (node) {
                    var value = node.get_value();
                    if (value.length > 0 && value % 2 == 0) {
                        args.IsValid = true;
                else {
                    args.IsValid = false;

    protected void RadComboBox1_OnItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
        this.RadComboBox1.Items.Add( new RadComboBoxItem("-- Select item --"));
        this.RadComboBox1.Items.Add(new RadComboBoxItem("Item with No Value"));
        this.RadComboBox1.Items.Add(new RadComboBoxItem("Item with Value=1", "1"));
        this.RadComboBox1.Items.Add(new RadComboBoxItem("Item with Value=2", "2"));
        this.RadComboBox1.Items.Add(new RadComboBoxItem("Item with Value=3", "3"));
        this.RadComboBox1.Items.Add(new RadComboBoxItem("Item with Value=4", "4"));

    Please note that if you use the RadComboBox control to raise the PostBack event (by setting the AutoPostBack to "true") -  naturally there will be no PostBack raised and the CustomValidator will not fire.

    All the best,
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Eric Villemure
    Eric Villemure avatar
    19 posts
    Member since:
    Feb 2008

    Posted 24 Aug 2010 Link to this post

    Hi, I think I've had the same problem as yours.

    I've found the solution here http://www.telerik.com/community/forums/aspnet-ajax/combobox/bug-custom-validation-in-particular-situation.aspx

    Let me know if it helps
Back to Top