By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
462,221 Members | 507 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 462,221 IT Pros & Developers. It's quick & easy.

HOW TO Change the textbox back color when focus, ASP.Net

P: 11
Hi all,

does any one know how to get the functionality of get focus and lost focus using ASP.Net like VB.Net

I want to change the textbox back ground color when it has the focus.

I used javascript to change the backgorund color when it has focus but how can I change the background color again when it lost the focus

my code is as below

javascript :

function change()
{
document.getElementById("<%=txtename.ClientID%>"). style.backgroundColor="red"
}

page load event

textbox1.attributes.add("onFocus", "change()")

Please Help me out

Thanks in Advance
May 31 '07 #1
Share this Question
Share on Google+
3 Replies

bartonc
Expert 5K+
P: 6,596
Moved from Member Introductions.
May 31 '07 #2

dip_developer
Expert 100+
P: 648
Hi all,

does any one know how to get the functionality of get focus and lost focus using ASP.Net like VB.Net

I want to change the textbox back ground color when it has the focus.

I used javascript to change the backgorund color when it has focus but how can I change the background color again when it lost the focus

my code is as below

javascript :

function change()
{
document.getElementById("<%=txtename.ClientID%>"). style.backgroundColor="red"
}

page load event

textbox1.attributes.add("onFocus", "change()")

Please Help me out

Thanks in Advance
If possible in the Onfocus event of another control(say another TextBox which gets focus after the first control)
change the colour of the first TextBox...
May 31 '07 #3

P: n/a
Try this it's working

Expand|Select|Wrap|Line Numbers
  1. <asp:TextBox ID="txtEmail" runat="server" onfocus="this.style.backgroundColor='yellow'"  onblur="this.style.backgroundColor='white'" ></asp:TextBox>
  2.  
Oct 9 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.