This is a migrated thread and some comments may be shown as answers.

Validation on RadComboBox

4 Answers 312 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Rahul
Top achievements
Rank 1
Rahul asked on 07 Jan 2014, 08:23 AM

on button click do a validation on RadCombobox

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 07 Jan 2014, 09:32 AM
Hi Rahul,

Please have a look into the sample code snippet to Validate RadComboBox.

ASPX:
<telerik:RadComboBox ID="RadComboBox2" runat="server" EmptyMessage="--Select--">
    <Items>
        <telerik:RadComboBoxItem Text="Item1" runat="server" />
        <telerik:RadComboBoxItem Text="Item2" runat="server" />
        <telerik:RadComboBoxItem Text="Item3" runat="server" />
    </Items>
</telerik:RadComboBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="RadComboBox2"
    ErrorMessage="Required">
</asp:RequiredFieldValidator>
<br />
<telerik:RadButton ID="RadButton2" runat="server" Text="Submit">
</telerik:RadButton>

Thanks,
Shinu.
0
Rahul
Top achievements
Rank 1
answered on 07 Jan 2014, 11:03 AM
Hi Shinu,
              Thanks for Reply. Actually i want to validate on Country,State,City and Main Road and its depend each other.
First time without selection I click the button they  Work  fine after that i select "Select Country" just empty message select they not work. so please suggest properly working example demo .

Thanks,
Rahul
0
Shinu
Top achievements
Rank 2
answered on 08 Jan 2014, 03:12 AM
Hi Rahul,

I guess that you are populating the RadComboBox from another RadComboBox based on some condition and you need to validate all the RadComboBox on Button Click. Please have a look into the following sample code snippet.

ASPX:
<telerik:RadComboBox ID="RadComboBox1" runat="server" AutoPostBack="True" EmptyMessage="--Select--"
    OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged">
</telerik:RadComboBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Required"
    ControlToValidate="RadComboBox1" ValidationGroup="Group1">
</asp:RequiredFieldValidator>
<telerik:RadComboBox ID="RadComboBox2" runat="server" AutoPostBack="True" EmptyMessage="--select--">
</telerik:RadComboBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Required"
    ControlToValidate="RadComboBox2" ValidationGroup="Group1">
</asp:RequiredFieldValidator>
<telerik:RadButton ID="RadButton1" runat="server" Text="Submit" ValidationGroup="Group1">
</telerik:RadButton>

C#:
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        //code for generating first radcombobox
    }
}
protected void RadComboBox1_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
{
    //code for generating second radcombobox
}

Please elaborate your requirement if it doesn't help.
Thanks,
Shinu.
0
Rahul
Top achievements
Rank 1
answered on 08 Jan 2014, 05:03 AM
Hi Shinu,
             Thanks for sample code. it's works...

Thanks,
Rahul
Tags
ComboBox
Asked by
Rahul
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Rahul
Top achievements
Rank 1
Share this question
or