AUTHOR: Rumen Zhekov
DATE POSTED: December 07, 2017
Change the background, text and border colors of RadButton SOLUTION The KB article shows how to programmatically update on click the RadButton's background, text and border colors. Since the background color is defined by a background-image gradient the code changes the background-image property value to none and applies a random background-color and color to RadButton body and its title:
<script>
function
OnClientClicking(button, args) {
var
$ = $telerik.$;
buttonID = button.get_id();
buttonWrapper = $(
"#"
+ button.get_id());
buttonWrapper.css(
"background-image"
,
"none"
);
"background-color"
, getRandomColor());
"color"
"border"
"1px solid "
+ getRandomColor());
}
getRandomColor() {
letters =
'0123456789ABCDEF'
;
color =
'#'
for
(
i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
return
color;
</script>
<telerik:RadButton ID=
"RadButton1"
Text=
"Button"
runat=
"server"
AutoPostBack=
"false"
OnClientClicked=
"OnClientClicking"
ButtonType=
"ToggleButton"
></telerik:RadButton>
Resources Buy Try