.NET Programming
--
Questions
--
Followers
Top Experts
i have a form in which there are labels and text boxes.
Now wha I am tring to do is when there is focus on a text box(user starts to enter text) back color of text box and label should be changed?
how do we that any code?
Asp.net VS2005
Sanjay
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
TextBox1.BackColor = System.Drawing.Color.Red;
    {
      textBox1.BackColor = Color.Yellow;
      label1.BackColor = Color.Yellow;
    }
    private void textBox1_Leave(object sender, EventArgs e) // Back to normal
    {
      textBox1.BackColor = Color.Transparent;
      label1.BackColor = Color.Transparent;
    }






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
in my aspx file when i click on text box and then press F4 propeties of that textbox are displayed
and when i switch to event part it does not display any enter or leave event
i typed this code in my aspx.cs file but nothing is happening
thanks
/Server Code
txtName.Attributes.Add("on
txtName.Attributes.Add("on
//Client Side Code
function SomeJavaScriptFunction(){
//Hi it's txtName's lost focus calling
//Hi txtName :)
}
  {
    TxtCompany.Attributes.Add(
     txtCompany.Attributes.Add(
  }
  private void txtCompany_Enter(object sender, EventArgs e) Â
  {
    TxtCompany.BackColor = Color.Yellow;
    lblmsg.BackColor = Color.Yellow;
  }
these lines are givin error when we click on the text box

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
txtEmail.Attributes.Add( "onFocus", "this.style.backgroundColo
 txtEmail.Attributes.Add( "onBlur", "this.style.backgroundColo
  {
    TxtCompany.Attributes.Add(
     txtCompany.Attributes.Add(
  }
  private void txtCompany_Enter() Â
  {
    TxtCompany.BackColor = Color.Yellow;
    lblmsg.BackColor = Color.Yellow;
  }
    private void textBox1_Leave() // Back to normal
    {
      textBox1.BackColor = Color.Transparent;
      label1.BackColor = Color.Transparent;
    }
okay this works
but when we call function  there is till error in the code
error is: object expected






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
this part is working fine if we only need to change color of the text box and when we do not want to change color of the label
.NET Programming
--
Questions
--
Followers
Top Experts
The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.