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

Problem Change the radtextbox backcolor

2 Answers 229 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
santhosh
Top achievements
Rank 2
santhosh asked on 08 Jan 2009, 01:31 PM
Hi,

I am having problem in changing the color of the radtextbox at the client side,
the color changes only after the control gets the focous, but i want it to happen immediately as soon as i click on the button.
below is the code, kindly advise

 

<script language="javascript" type="text/javascript">

 

 

function validate()

 

{

 

var name = $find("<%= radtxtLastName.ClientID %>");

 

 

var name1= document.getElementById('radtxtFirstName');

 

alert(name1.value);

name1.style.background =

"red";

 

 

if(name.get_value()=="")

 

{

name.get_styles().EnabledStyle[0] =

"background-color: Red;";

 

 

return false;

 

}

 

return true;

 

}

 

</script>

 

 

<telerik:RadTextBox ID="radtxtLastName" runat="server" Width="250px" MaxLength="50" skin="Office2007"/>

 

 

<asp:TextBox ID="radtxtFirstName" runat="server" Width="250px" MaxLength="50"></asp:TextBox>

 

 

<asp:ImageButton ID="btnChange" ImageUrl="~/Images/btn_ok.gif" runat="server" OnClientClick="return validate()" />


Regards,

Santhosh

 

2 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 08 Jan 2009, 02:12 PM
Hello Santhosh,

After this:

name.get_styles().EnabledStyle[0] = "background-color: Red;";


you must execute this:

name.updateCssClass();


Otherwise the changes will not be applied immediately. This is demonstrated here:

http://www.telerik.com/help/aspnet-ajax/input_clientsidebasics.html


Greetings,
Dimo
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
santhosh
Top achievements
Rank 2
answered on 09 Jan 2009, 02:12 PM
Hi Dimo,

Thanks a lot, it worked.

Regards,

Santhosh
Tags
General Discussions
Asked by
santhosh
Top achievements
Rank 2
Answers by
Dimo
Telerik team
santhosh
Top achievements
Rank 2
Share this question
or