RadioButtonList - ASP.NET Validators Support

#3 Which type of apps is the most useful to you?
 
Isolate this demo as a stand-alone application
  • About this demo
  • C#
  • VB

As of R1 2017 RadioButtonList control can be integrated with the native ASP.NET RequiredFieldValidator.

As shown in this demo, you just need to put the needed validator control and set the ControlToValidate value to the ID of the RadioButtonList's ID.

<telerik:RadRadioButtonList runat="server" ID="Questionnaire" AutoPostBack="false">
    <Items>
        <telerik:ButtonListItem Text="Game apps (puzzles, charades, etc.)" Value="0" />
        ...
    </Items>
</telerik:RadRadioButtonList>
 
<asp:RequiredFieldValidator ID="QuestionnaireValidator" runat="server"
    ControlToValidate="Questionnaire" 
    ErrorMessage="..." />

This will validate the SelectedItem property of the RadioButtonList control on submit and return the appropriate validation result.

  • DefaultCS.aspx
  • styles.css
<%@ Page Language="C#"  %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
    <link href="styles.css" rel="stylesheet" />
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <div class="demo-container questionnaire">
        <div class="title">#3 Which type of apps is the most useful to you?</div>

        <telerik:RadRadioButtonList runat="server" ID="Questionnaire" AutoPostBack="false" CssClass="content">
            <Items>
                <telerik:ButtonListItem Text="Game apps (puzzles, charades, etc.)" Value="0" />
                <telerik:ButtonListItem Text="Sports apps (sports schedules, scores, headlines, etc.)" Value="1" />
                <telerik:ButtonListItem Text="Travel apps (airplane tickets, tourist guides, transportation info, etc.)" Value="2" />
                <telerik:ButtonListItem Text="News apps (news, national headlines, technology announcements, etc.)" Value="3" />
                <telerik:ButtonListItem Text="Entertainment apps (puzzles, charades, etc.)" Value="4" />
                <telerik:ButtonListItem Text="Other" Value="7" />
            </Items>
        </telerik:RadRadioButtonList>

        <asp:RequiredFieldValidator ID="QuestionnaireValidator" runat="server" 
            ControlToValidate="Questionnaire" ForeColor="Red" CssClass="questionnaire-validation-message"
            ErrorMessage="Please choose one of the options displayed" />

        <telerik:RadPushButton runat="server" Text="Next" CssClass="questionnaire-btn" />
    </div>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance

Help Us Improve

Was this example helpful?