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

RadButton with ContentTemplate not showing radio button

2 Answers 174 Views
Button
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 1
Brian asked on 01 May 2012, 09:56 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Slav
Telerik team
answered on 02 May 2012, 08:56 AM
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.
0
Brian
Top achievements
Rank 1
answered on 02 May 2012, 05:06 PM
Thanks Slav. Your simple solution worked.
Tags
Button
Asked by
Brian
Top achievements
Rank 1
Answers by
Slav
Telerik team
Brian
Top achievements
Rank 1
Share this question
or