How to change the background color in the Textbox on focus ?

Dec 21, 2009 Posted by Lara Kannan

I searched the solution for the following situation. In web application, gridview contains textbox in each row. When there is focus on the textbox, the background colour of the textbox must be yellow with bold otherwise it must be black with white text.

See the sample code: we reach the solution by simply adding onfocus and onblur event to the text box.


<asp:TextBox ID="text1" runat="server"
onFocus=" ='yellow'"


Happy coding!

Labels: ,

Post a Comment