New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

ContentTemplate

This help article showcases how to add complex content (server-side controls and HTML elements) in a RadButton instead of plain text. You can do this both in the markup, or in the code behind:

Add Elements to RadButton in the Markup

In order to add controls to the RadButton in the markup, you should place them directly in the composite ContentTemplate property (Example 1).

Example 1: Adding controls to the ContentTemplate of a RadButton in the markup.

ASP.NET
<telerik:RadButton RenderMode="Lightweight" runat="server" ID="RadButton1">
	<ContentTemplate>
		<img alt="cog" src="https://demos.telerik.com/aspnet-ajax/button/examples/contenttemplate/Img/cog.png" />
		<span>Tasks</span>
		<telerik:RadRating RenderMode="Lightweight" ID="RadRating1" runat="server" Enabled="false" Value="3" SelectionMode="Continuous" ItemCount="5" />
	</ContentTemplate>
</telerik:RadButton>

Add Elements to RadButton from the Code-behind

You can add controls to the RadButton from the code-behind in two ways:

  • Add elements to the Controls collection of the RadButton (Example 2).Example 2: Adding controls to the Controls collection of RadButton from code behind.
ASP.NET
<telerik:RadButton RenderMode="Lightweight" runat="server" ID="RadButton1" Width="160px" Height="70px">
</telerik:RadButton>
  • Set the ContentTemplate property to an instance of a class that implements the ITemplate interface (Example 3).Example 3: Adding controls to the RadButton by using the ITemplate class.
ASP.NET
<telerik:RadButton RenderMode="Lightweight" runat="server" ID="RadButton1" Width="160px" Height="70px">
</telerik:RadButton>

See Also