RadComboBox validation not Working

9 posts, 0 answers
  1. Jose Luis
    Jose Luis avatar
    2 posts
    Member since:
    Feb 2011

    Posted 29 Nov 2011 Link to this post

    Hi,
    I have an application with some telerik:RadComboBox and asp:RequiredFieldValidator to validate empty value.  But it's not working and it's not validating.  I checked the radscript manager and I have an error (Error Creating Control).

    I had the application with NET Framework 2.0 and I changed to NET Framework 3.5.  I have instaled Telerik ASP NET Q1 2010

    Is it compatible that version of telerik with .NET framework 3.5?
    What does the problem with combobox validation?

    this si my html:

    <telerik:RadComboBox ID="lstCountry" runat="server" AutoPostBack="True"
    onselectedindexchanged="lstCountry_SelectedIndexChanged" SkinID="DropDownList" 
    TabIndex="17" Width="240px"  >
    </telerik:RadComboBox>
    <asp:RequiredFieldValidator ID="rfvCountry" runat="server" 
       ControlToValidate="lstCountry" ErrorMessage="Country is required" InitialValue=""
    SkinID="RequiredFieldValidator" ValidationGroup="vgpSave"  Text="*">
    </asp:RequiredFieldValidator>

    Regards

    Jose
  2. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 02 Dec 2011 Link to this post

    Hi Jose,

    Yes, 2010 Q1 release is compatible with .Net Framework 2.0, 3.5 and 4.0.

    I have tested your scenario with version 2010.1.309.35, and the RequiredFieldValidator works as expected, it is activated when the input field of the RadComboBox contains no text.
    Here is what I have been testing:
    <telerik:RadComboBox ID="RadComboBox1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged"
     SkinID="DropDownList" TabIndex="17" Width="240px">
        <Items>
            <telerik:RadComboBoxItem Value="" Text="" />
            <telerik:RadComboBoxItem Value="value2" Text="item2" />
            <telerik:RadComboBoxItem Value="value3" Text="item3" />
            <telerik:RadComboBoxItem Value="value3" Text="item3" />
        </Items>
    </telerik:RadComboBox>
    <asp:RequiredFieldValidator ID="rfvCountry" runat="server" ControlToValidate="RadComboBox1"
        ErrorMessage="Country is required" SkinID="RequiredFieldValidator">
    </asp:RequiredFieldValidator>

    If you are still having troubles, could you please send us a support ticket with a running sample page attached to it, so we will be able to troubleshoot the issues locally.

    Kind regards,
    Ivana
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jose Luis
    Jose Luis avatar
    2 posts
    Member since:
    Feb 2011

    Posted 06 Dec 2011 Link to this post

    Ok, But when I set a dynamic list to radcombobox it not validate empty values.

    For example: lstCountry is a dynamic list from database

    <telerik:RadComboBox ID="lstCountry" runat="server" AutoPostBack="True"

    onselectedindexchanged="lstCountry_SelectedIndexChanged" SkinID="DropDownList"  

    TabIndex="17" ToolTip="Country"

    Width="240px">  

    </telerik:RadComboBox>

     

    <asp:RequiredFieldValidator ID="rfvCountry" runat="server"

    ControlToValidate="lstCountry" ErrorMessage="Country is required" InitialValue=""

    SkinID="RequiredFieldValidator" ValidationGroup="vgpSave" Text="*">

    </asp:RequiredFieldValidator>

     

    Here the filling of the list:

     

    public void ShowCountries(List<NumberTO> lCountries)

     {

    lstCountry.Items.Clear();

    lstCountry.DataSource = lCountries;

    lstCountry.DataTextField = "Country";

    lstCountry.DataValueField = "Country";

    lstCountry.DataBind();

    lstCountry.Items.Insert(0, new RadComboBoxItem("", ""));

     }

    Regards

    Jose

     

  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 07 Dec 2011 Link to this post

    Hello,

    I have tried the same and it worked as expected. I am using the version 2011, 2, 915, 35. Here is the sample code.

    CS:
    protected void Page_Load(object sender, EventArgs e)
     {
         String s = "select FirstName,EmployeeID from Employees";
         con.Open();
         SqlDataAdapter dr = new SqlDataAdapter(s, con);
         DataTable dt = new DataTable();
         dr.Fill(dt);
         con.Close();
         rcmb1.DataSource = dt;
         rcmb1.DataTextField = "EmployeeID";
         rcmb1.DataValueField = "FirstName";
         rcmb1.DataBind();
         rcmb1.Items.Insert(0, new RadComboBoxItem(""));
      }

    ASPX:
    <telerik:RadComboBox ID="rcmb1" runat="server">
    </telerik:RadComboBox>
    <asp:RequiredFieldValidator ID="ReqiredFieldvalidator1" runat="server" ControlToValidate="rcmb1" ErrorMessage="Value is required"  Text="*">
    </asp:RequiredFieldValidator>

    Thanks,
    Princy.
  6. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 09 Dec 2011 Link to this post

    Hello Jose,

    Could you please open a support ticket and send us a runnable sample page with the behavior in question reproduced in it? This way we will be able to troubleshoot the issues locally, and determine where the problem comes from.

    Regards,
    Ivana
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  7. Saktheeswaran
    Saktheeswaran avatar
    7 posts
    Member since:
    Feb 2014

    Posted 04 May 2014 Link to this post

    Hi Guys,

    I have some radcombobox in my aspx page and I have validate it.

    The code is below

     <telerik:RadComboBox ID="RcFilterchanged" runat="server" CssClass="GridTextBoxTXT" EmptyMessage="- Choose one -">
                                <Items>
                                    <telerik:RadComboBoxItem Text="- Choose one -" Value="0" />
                                    <telerik:RadComboBoxItem Text="Yes" Value="1" />
                                    <telerik:RadComboBoxItem Text="No" Value="2" />
                                </Items>
                            </telerik:RadComboBox>
                            <br />
                            <asp:RequiredFieldValidator runat="server" ID="Rq5" InitialValue="- Choose one -"
                                ControlToValidate="RcFilterchanged" ValidationGroup="S1" ErrorMessage="Please Choose one"
                                CssClass="validator" />


    If I remove the EmptyMessage in radcombobox, the validation work fine. At the Same time in my radcombobox have EmptyMessage its not work.. what the reason.?

    Thanks Advance..


  8. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 05 May 2014 in reply to Saktheeswaran Link to this post

    Hi Saktheeswaran,

    Please do the following modifications in your code snippet which works fine at my end.

    ASPX:
    <telerik:RadComboBox ID="RcFilterchanged" runat="server" CssClass="GridTextBoxTXT"
        ValidationGroup="S1" EmptyMessage="- Choose one -">
        <Items>
            <telerik:RadComboBoxItem Text="Yes" Value="1" />
            <telerik:RadComboBoxItem Text="No" Value="2" />
        </Items>
    </telerik:RadComboBox>
    <br />
    <asp:RequiredFieldValidator runat="server" ID="Rq5" ControlToValidate="RcFilterchanged"
        ValidationGroup="S1" ErrorMessage="Please Choose one" CssClass="validator" />

    Let me know if you have any concern.
    Thanks,
    Shinu.
  9. Saktheeswaran
    Saktheeswaran avatar
    7 posts
    Member since:
    Feb 2014

    Posted 06 May 2014 in reply to Shinu Link to this post

    Hi Shinu,

    Thanks for quick reply. It's work fine.

    I have another one issue in Radcombobox application. In My Radcombobox have a check box option. now its have 10 items (ex. Item1, Item2 ... Item10). At first in add mode I have selected 3 values (ex Item2, Item 5 and Item9) and it saved to backend.  Now In my edit mode how to select the existing selected 3 items.

    Thanks..
  10. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 07 May 2014 in reply to Saktheeswaran Link to this post

    Hi Saktheeswaran,

    Please have a look into the sample code snippet which works fine at my end.

    ASPX:
    <telerik:RadComboBox ID="RcFilterchanged" runat="server" CssClass="GridTextBoxTXT"
        CheckBoxes="true" ValidationGroup="S1" EmptyMessage="- Choose one -">
        <Items>
            <telerik:RadComboBoxItem Text="Item1" Value="1" />
            <telerik:RadComboBoxItem Text="Item2" Value="2" />
            <telerik:RadComboBoxItem Text="Item3" Value="3" />
            <telerik:RadComboBoxItem Text="Item4" Value="4" />
            <telerik:RadComboBoxItem Text="Item5" Value="5" />
            <telerik:RadComboBoxItem Text="Item6" Value="6" />
            <telerik:RadComboBoxItem Text="Item7" Value="7" />
            <telerik:RadComboBoxItem Text="Item8" Value="8" />
            <telerik:RadComboBoxItem Text="Item9" Value="9" />
            <telerik:RadComboBoxItem Text="Item10" Value="10" />
        </Items>
    </telerik:RadComboBox>
    <br />
    <telerik:RadButton ID="radbtnSaveItem" runat="server" Text="Save Checked Items" OnClick="radbtnSaveItem_Click">
    </telerik:RadButton>
    <telerik:RadButton ID="radbtnEditItem" runat="server" Text="Get Checked Items" OnClick="radbtnEditItem_Click">
    </telerik:RadButton>

    C#:
    public static string[] checkedItems = new string[10];
    protected void radbtnSaveItem_Click(object sender, EventArgs e)
    {
        int index = 0;
        foreach (RadComboBoxItem item in RcFilterchanged.CheckedItems)
        {
            checkedItems[index] = item.Text; //saving all checked items in the string array
            index++;
        }
        RcFilterchanged.ClearCheckedItems();
    }
    protected void radbtnEditItem_Click(object sender, EventArgs e)
    {
        for (int index = 0; index < checkedItems.Length; index++)
        {
            if (checkedItems[index] != null)
            {
                //accessing the previously checked items and setting it as checked
                RadComboBoxItem item = RcFilterchanged.FindItemByText(checkedItems[index]) as RadComboBoxItem;
                item.Checked = true;
            }
            else
                break;
        }
    }

    Let me know if you have any concern.
    Thanks,
    Shinu.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017