RadButton with ContentTemplate not showing radio button

3 posts, 1 answers
  1. Brian
    Brian avatar
    12 posts
    Member since:
    Apr 2012

    Posted 01 May 2012 Link to this post

    I've created two radio buttons

    <telerik:RadButton ID="rbOption1" runat="server" Text="option 1" ToggleType="Radio"
        GroupName="group1" ButtonType="ToggleButton" />
    <br />
    <telerik:RadButton ID="rbOption2" runat="server" ToggleType="Radio"
        GroupName="group1" ButtonType="ToggleButton">
        <ContentTemplate>
            <asp:Label ID="lblChoose" runat="server" Text="choose" />
            <asp:DropDownList ID="ddlChoose" runat="server" />
        </ContentTemplate>
    </telerik:RadButton>

    I want the second radbutton to be rendered with a radio button just the the first radbutton. But instead the entire contents of the content template is being rendered as an html anchor. Is there a way to use the radbutton to look like my attached mockup?
  2. Answer
    Slav
    Admin
    Slav avatar
    1355 posts

    Posted 02 May 2012 Link to this post

    Hi Brian,

    A RadButton with specified content via the ContentTemplate inner property is displayed in a LinkButton mode. Note that this feature is designed for controlling the appearance of the button control and the behavior of any ASP controls in the RadButton's content that use events will most probably be altered because of the button's functionality.

    You can achieve the desired effect simply by using another RadButton, configured as radio button, and a DropDownList that will be enabled only when a particular radio button is checked. The following example demonstrates this setup:

    Page markup:
    <telerik:RadButton ID="rbOption1" runat="server" Text="option 1" ToggleType="Radio"
        GroupName="group1" ButtonType="ToggleButton" />
    <br />
    <telerik:RadButton ID="rbOption2" runat="server" Text="choose" ToggleType="Radio"
        GroupName="group1" ButtonType="ToggleButton" />
    <asp:DropDownList ID="ddlChoose" runat="server" Enabled="false">
        <asp:ListItem Text="Text" Value="Value"></asp:ListItem>
        <asp:ListItem Text="Text" Value="Value"></asp:ListItem>
    </asp:DropDownList>
    <br />

    Code-behind:
    protected void Page_Load(object sender, EventArgs e)
    {
        ddlChoose.Enabled = rbOption2.Checked;
    }

    Greetings,
    Slav
    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. Brian
    Brian avatar
    12 posts
    Member since:
    Apr 2012

    Posted 02 May 2012 Link to this post

    Thanks Slav. Your simple solution worked.
Back to Top