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

Add Elements in Radio Button Runtime

1 Answer 55 Views
Button
This is a migrated thread and some comments may be shown as answers.
Krishna
Top achievements
Rank 1
Krishna asked on 01 Aug 2012, 03:20 PM
How can we change image source in Readion Button Content Template at run time depending on specific condition?



<telerik:RadButton runat="server" ID="RadButton1" Width="90"
           Height="90" CssClass="tasks" Skin="Default">
           <ContentTemplate>
               <img alt="cog" src="Img/cog.png" />
               <span class="btnText">Tasks</span>
           </ContentTemplate>
       </telerik:RadButton>

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 02 Aug 2012, 04:51 AM
Hi Krishna,

Here is the sample code that I tried to change the image source dynamically.

ASPX:
<telerik:RadButton runat="server" ID="RadButton1" Width="90" Height="90" CssClass="tasks" Skin="Default">
  <ContentTemplate>
    <img alt="cog" src="../Images/image1.jpg" id="image" runat="server" />
    <span class="btnText">Tasks</span>
  </ContentTemplate>
</telerik:RadButton>

C#:
if(Your Condition)
  {
    HtmlImage img =(HtmlImage) RadButton1.FindControl("image");
    img.Src = "../Images/image2.jpg";
  }
else
  {
    HtmlImage img =(HtmlImage) RadButton1.FindControl("image");
    img.Src = "../Images/image3.jpg";
  }

Hope this helps.

Regards,
Princy.
Tags
Button
Asked by
Krishna
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or