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

Changing the Skin or CSS using javascript(clientside)

3 Answers 317 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Nambi
Top achievements
Rank 1
Nambi asked on 11 Sep 2011, 01:19 PM
Hi ,
What is the equivalent of className property in telerik controls.I want to update the css based on client click using javascript.


<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
            <script type="text/javascript" language="javascript">

            function AssignValue() {
                var rdtb1 = document.getElementById('<%#rdtb1.ClientID%>');                
                    rdtb1.className = "red_bgd";
                    rdtb1.skin = "red_bgd";              
            }
    </script>
        <style type="text/css">
    .red_bgd{
    background-color:#F8E5E5;
   color:#A90000;    
}   
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
               <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
             <telerik:RadTextBox ID="rdtb1" Runat="server" EnableEmbeddedSkins="false" >
        </telerik:RadTextBox>
        <br />
        <br />
           <asp:Button ID="btnFillRdTb" runat="server"   Text="FillTextBox" onClientClick="AssignValue()" />
    </div>
    </form>
</body>
</html>

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 12 Sep 2011, 01:37 PM
Hello Nambi,

Check the following forum thread which explains the similar scenario.
add cssClass dynamically to telerik rad input text box.

Thanks,
Princy.
0
Nambi
Top achievements
Rank 1
answered on 12 Sep 2011, 03:02 PM
Hello Princy,
      Thanks for the quick reply. When i click on a button css is changing for a second but goes off ie. become normal during post back.





<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
            <script type="text/javascript" language="javascript">

            function AssignValue() {
            var tb = $find('rdtb1');
tb.get_styles().EnabledStyle[1] += " red_bgd";
tb.updateCssClass();
            }         
    </script>
        <style type="text/css">
    .red_bgd{
    background-color:#F8E5E5!important;
   color:#A90000!important;    
}   
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
               <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
             <telerik:RadTextBox ID="rdtb1" Runat="server"  EnableEmbeddedSkins="false" >
        </telerik:RadTextBox>
        <br />
        <br />
           <asp:Button ID="btnFillRdTb" runat="server"   Text="FillTextBox" onClientClick="AssignValue()" />
    </div>
    </form>
</body>
</html>
0
Princy
Top achievements
Rank 2
answered on 13 Sep 2011, 04:43 AM
Hello Nambi,

Try setting return false on OnClientClick event.
aspx:
<asp:Button ID="btnFillRdTb" runat="server"   Text="FillTextBox" onClientClick="AssignValue(); return false;" />

Thanks,
Princy.
Tags
General Discussions
Asked by
Nambi
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Nambi
Top achievements
Rank 1
Share this question
or