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

clientevents OnFocus

1 Answer 116 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Vitaly
Top achievements
Rank 1
Iron
Iron
Vitaly asked on 20 Mar 2014, 07:33 PM

Good afternoon,

I have in my aspx page RadTextBox:

 

<

 

 

 

telerik:RadTextBox ID="CFNTextBox" runat="server" Font-Bold="true" TabIndex="1" Width="150px" CssClass="textbox" >

I would like fire on clientevent OnFocus and OnBlur to change backgroundColor.

When focus gets on textbox one color and when focus leaves textbox another color.

How can I do that?

Thanks so much for your help.

 

​​​​​​​​

 

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 21 Mar 2014, 03:44 AM
Hi Vitaly,

Please try the following code snippet to change the background color of RadTextBox in OnFocus and OnBlur event.

ASPX:
<telerik:RadTextBox ID="CFNTextBox" runat="server" Font-Bold="true" TabIndex="1"
    ClientEvents-OnBlur="OnBlur" ClientEvents-OnFocus="OnFocus" Width="150px" CssClass="textbox">
</telerik:RadTextBox>

JavaScript:
<script type="text/javascript">
    function OnFocus(sender, args) {
        sender._element.style.backgroundColor = "red";
    }
    function OnBlur(sender, args) {
        sender._element.style.backgroundColor = "blue";
    }
</script>

Thanks,
Shinu.
Tags
General Discussions
Asked by
Vitaly
Top achievements
Rank 1
Iron
Iron
Answers by
Shinu
Top achievements
Rank 2
Share this question
or