How do i add a class to rad button dynamically code behind

2 posts, 0 answers
  1. Philip
    Philip avatar
    69 posts
    Member since:
    Mar 2016

    Posted 05 Jun Link to this post

    I am using the following mark up for a toolbar at the top of my screen but their is a diabled css class that i can add and an active to make them stand out my question is how do i in code behind add a style to the button cssclass tag.

     

    <telerik:RadButton ID="rbPersonalDetails" runat="server" CssClass="btn btn-info" Text="Property Details">
     
                    <ContentTemplate>
                        <i class="fa fa-user" style="color: #5bc0de;"></i>Personal Details
                    </ContentTemplate>
     
                </telerik:RadButton>
                <telerik:RadButton ID="rbPropertyDetails" runat="server" CssClass="btn btn-info" Text="Property Details">
     
                    <ContentTemplate>
                        <i class="fa fa-home" style="color: #5bc0de;"></i>Property Details
                    </ContentTemplate>
     
                </telerik:RadButton>
                <telerik:RadButton ID="rbVechicleDetails" runat="server" CssClass="btn btn-info" Text="Vechicle Details">
     
                    <ContentTemplate>
                        <i class="fa fa-car" style="color: #5bc0de;"></i>Vechicle Details
                    </ContentTemplate>
     
                </telerik:RadButton>
     
                <telerik:RadButton ID="rbincomee" runat="server" CssClass="btn btn-info">
     
                    <ContentTemplate>
                        <i class="fa fa-gbp" style="color: #5bc0de;"></i>Income & Expenditures
                    </ContentTemplate>
     
                </telerik:RadButton>
     
     
     
                <telerik:RadButton ID="rbPensions" runat="server" CssClass="btn btn-info">
     
                    <ContentTemplate>
                        <i class="fa fa-bank" style="color: #5bc0de;"></i>Pensions
                    </ContentTemplate>
     
                </telerik:RadButton>
     
                <telerik:RadButton ID="rbMeetings" runat="server" CssClass="btn btn-info">
     
                    <ContentTemplate>
                        <i class="fa fa-calendar" style="color: #5bc0de;"></i>Meetings
                    </ContentTemplate>
     
                </telerik:RadButton>
     
                <telerik:RadButton ID="rbOtherAssets" runat="server" CssClass="btn btn-info" >
     
                    <ContentTemplate>
                        <i class="fa fa-share" style="color: #5bc0de;"></i>Other Assets
                    </ContentTemplate>
     
                </telerik:RadButton>

  2. Misho
    Admin
    Misho avatar
    129 posts

    Posted 08 Jun Link to this post

    Hello,

    Here is the sample that is showing how to add custom css class to RadButton in the code behind:

    <form id="form1" runat="server">
     
           <asp:ScriptManager runat="server"></asp:ScriptManager>
           <asp:Button runat="server" Text="Disable RadButton" OnClick="ButtonClicked"/>
           <telerik:RadButton ID="rbPersonalDetails" runat="server" CssClass="btn btn-info" Text="Property Details">
               <ContentTemplate>
                   <i class="fa fa-user" style="color: #5bc0de;"></i>Personal Details
               </ContentTemplate>
           </telerik:RadButton>
           <telerik:RadButton ID="RadButton1" runat="server" CssClass="btn btn-info" Enabled="false" Text="Property Details">
               <ContentTemplate>
                   <i class="fa fa-user" style="color: #5bc0de;"></i>Personal Details
               </ContentTemplate>
           </telerik:RadButton>
           <telerik:RadButton ID="RadButton2" runat="server" CssClass="btn btn-info"  Text="Property Details">
               <ContentTemplate>
                   <i class="fa fa-user" style="color: #5bc0de;"></i>Personal Details
               </ContentTemplate>
           </telerik:RadButton>
           <div>
           </div>
     
     
           <script runat="server">
               protected void Page_Load(object sender, EventArgs e)
       {
           if (!IsPostBack)
           {
               Response.Write(RadButton2.CssClass);
           }
       }
     
       protected void ButtonClicked(object sender, EventArgs e)
       {
           rbPersonalDetails.Enabled = false;
           RadButton2.CssClass += " disabled";
           Response.Write(RadButton2.CssClass);
       }
     
           </script>
       </form>
     In addition you can review the following help article:

    http://docs.telerik.com/devtools/aspnet-ajax/controls/button/server-side-programming/properties-and-events#radbuttontogglestate-specific-features-properties

    I hope that helps.

    Regards,
    Misho
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top