Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6603221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:58:48+00:00 2026-05-25T18:58:48+00:00

I am using asp.net text box and I am showing the border for the

  • 0

I am using asp.net text box and I am showing the border for the text box on mouse hover event and its pretty well doing it’s job for the first time and when I click on the text box and again click outside the textbox and If I mouse hover the same textbox it dosen;t show me the border.

Can anyone say me where I am doing wrong?
Thanks in advance!

Here is my css code:

 .onfocus
{
    border-width: thin;
    border-color: #0033CC;
}
.onblur
{
border:0px;
}

    .MyTextbox:hover{border:1px solid red;}

Here is how I am using it:

<script type ="text/javascript">
  function Change(obj, evt) {
      if (evt.type == "focus")
          obj.className = "onfocus";
      else if (evt.type == "blur")
          obj.className = "onblur";
  }

  <asp:TextBox ID="txtUsername" runat="server" Style="position: absolute; top: 76px;
            left: 24px; width: 189px; height: 24px; outline: none;" onfocus ="Change(this, event)"
        onblur ="Change(this, event)" BackColor="#FAFFBD" CssClass="MyUsername" ></asp:TextBox>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:58:48+00:00Added an answer on May 25, 2026 at 6:58 pm

    The hover is not working the second time because your javascript code on focus/blur is changing the class value for the textbox so that it no longer has the “MyTextbox” class. Since your border change on hovering is done based on the MyTextbox class, it no longer works after that.

    What you should be doing instead of setting obj.className = "onfocus", is to add the “onfocus” class to the existing value so that it is not lost. Then, during the blur event, you would remove the onfocus class, and add in the onblur class (again, not just totally replacing the className value).

    This question has some good answers about how you can properly add/remove the extra classes in either plain javascript or with jQuery (which makes it much easier).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using asp.net 2.0 I set a hidden text box from javascript and
I'm developing a web application using asp.net. There is a text box which contains
Using ASP.net, how do you write ANSI characters to a text file? I need
Using ASP.NET VB, I have a form with some text boxes and a Gridview.
I am having an aspx page where I have added one asp.net text box
I have a simple ASP.Net MVC View which contains an FCKeditor text box (created
I'm working in ASP.NET and have a text box in which I enter First
I am working in asp.net and have a text box txtRateOfPay and a dropdown
I'm using ASP.NET, but on a certain page I am using regular html text
i am using asp.net and vb.net in my student.aspx have a row of text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.