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

RequiredFieldValidator

1 Answer 102 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Sonia
Top achievements
Rank 1
Sonia asked on 17 Oct 2013, 08:42 AM
Hi, 
I am trying RequiredFieldValidator with RadDropDownList but i cannot manage to capture when no item is selected.
Please, see below the code which implements it. 
It is possible that setting DefaultMessage causes that always there is an item selected and requiredfieldvalidator never notifies that?


<
telerik:RadDropDownList ID="Indicator_Period" runat="server" DefaultMessage="Select period">
                                    <Items>
                                        <telerik:DropDownListItem Text="Dayly" Value="d" />
                                        <telerik:DropDownListItem Text="Monthly" Value="m" />
                                        <telerik:DropDownListItem Text="Bimonthly" Value="b" />
                                        <telerik:DropDownListItem Text="Three-monthly" Value="t" />
                                        <telerik:DropDownListItem Text="Four-monthly" Value="c" />
                                        <telerik:DropDownListItem Text="Six-monthly" Value="s" />
                                        <telerik:DropDownListItem Text="Yearly" Value="a" />
                                    </Items>
                                </telerik:RadDropDownList>
                                <asp:RequiredFieldValidator ID="Indicator_Period_RequiredFieldValidator" runat="server" ErrorMessage="*" ControlToValidate="Indicator_Period" ValidationGroup="AddIndicatorValidationGroup" ForeColor="Red"></asp:RequiredFieldValidator>
 
<telerik:RadButton ID="RadButton1" runat="server" Text="Save" ButtonType="StandardButton"
        OnClick="SaveIndicator" ValidationGroup="AddIndicatorValidationGroup">
        <Icon PrimaryIconCssClass="rbSave" PrimaryIconLeft="4" PrimaryIconTop="4"></Icon>
    </telerik:RadButton>

1 Answer, 1 is accepted

Sort by
1
Shinu
Top achievements
Rank 1
answered on 21 Oct 2013, 07:41 AM
Hi Sonia,

RadDropDownList does not have any known issues with ASP RequiredFieldValidator. I have tried the code you posted and it works fine at my end. The DefaultMessage displayed in the RadDropDownList wont be treated as a selected item and it wont interfere the working of the RequiredFieldValidator. Also check whether you are setting any InitialValue to the RequiredFieldValidator some where from the code which can affect the working of the RequiredFieldValidator.

Thanks,
Shinu.
Tags
DropDownList
Asked by
Sonia
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Share this question
or