473,770 Members | 6,736 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

11 New Member
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.getEle mentById("<%=tx tename.ClientID %>").style.back groundColor="re d"
}

page load event

textbox1.attrib utes.add("onFoc us", "change()")

Please Help me out

Thanks in Advance
May 31 '07 #1
3 11512
bartonc
6,596 Recognized Expert Expert
Moved from Member Introductions.
May 31 '07 #2
dip_developer
648 Recognized Expert Contributor
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.getEle mentById("<%=tx tename.ClientID %>").style.back groundColor="re d"
}

page load event

textbox1.attrib utes.add("onFoc us", "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
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

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

Similar topics

1
3292
by: Chris Mayers | last post by:
Hi, I have an application that has (for the sake of argument) 2 (MDI) windows open. If I click into a textbox on FormA then the 'Enter' event for that TextBox fires, great! However, if I then click on FormB, then back to FormA although the cursor is still flashing in the same textbox on FormA, when I tab out, the 'Leave' event for that TextBox does not fire. If I stay on FormA and Shift-Tab back into the textbox then the 'Enter' event...
2
6160
by: JayDee | last post by:
After a user enters data into a field, I need to populate other controls on the form, based on the user entry. I have to use either Leave, Validating or Validated, and I take it I can't use LostFocus because there is no selection for that event in the dropdown list on the code page. What's happening is that all 3 events mentioned above for the textbox control fire in the proper order when the form is invoked, but don't fire the first time...
7
37988
by: deko | last post by:
I have a textbox in a form into which users enter a string to execute a search. After the user presses Enter, I'd like the focus to go back to the textbox, but the default behavior of the Enter Key moves the focus to the next control. Here's the code: Private Sub txtFind_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then Call cmdFind_Click
3
19717
by: Jose Egea | last post by:
Hello: I'm trying to execute a function when the user press Enter key in a TextBox. But something is happening in my form because after pressing a button, when I press the Enter key in the TextBox, the application executes the click event of the last button selected instead of the keypress event of the TextBox. Any key event happen in my form, even the keypreview event is ignored. The propertie AcceptsReturn is set to false and...
7
4362
by: joey.powell | last post by:
I have a home page with username and password textboxes and a login button for purposes of users being able to log in (forms authentication) directly on the site home page. I also have a dedicated "Login.aspx" page, but I don't want users redirected there unless absolutely necessary. I have registered a javascript block via "Page.RegisterStartupScript" that sets focus to the "txtUserName" textbox control on Page Load. It works great...
0
1086
by: Wayne Wengert | last post by:
I have a form on which I change background colors when textbox get focus and I reset the background color when it loses focus. This works fine except when I change the focus via code. If I validate the contents of several textbox values from a subroutine and find txtBox3 has invalid contents I display an error msg and then issue txtBox3.Focus and exit the sub the cursor is in txtBox3 but the background color of the last textbox into which...
0
1383
by: Agnes | last post by:
I had created a textbox usercontrol , My aim is "once the textbox got focus, its backcolor become lightgray", lost focus will change back to default.Please be kind to help. Private Sub stdTextBox_Gotfocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.GotFocus If Me.pMask = Mask.None Then Me.pPrevious_value = Me.Text ' pPrevColor = Me.BackColor Me.BackColor = System.Drawing.Color.Azure End Sub
3
2178
by: Gidi | last post by:
Hi, I've a form with few TextBoxes and in all i'm writing in language A except one which i want to write in language B (both A and B are installed on my PC). how can I make the specific textBox to write in language B when it has the focus and get back to language A when it loses it. I tried to send Alt+Shift and it's working when i move from one TextBox to the other, but then when i leave the form (OnClosing i.e.) i'm stuck with...
10
18048
by: engteng | last post by:
When textbox properties enable = False the font in the textbox become gray color. How do I change the gray color to black color ? Regards, Tee
0
9591
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10225
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10053
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10001
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9867
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5312
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3969
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3573
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.