我现在想在文本框获得焦点的时候去触发一个事件.
可是ASP.NET里文本框没有焦点事件.假设当TEXT1获得焦点的时候.
让Lable1的背景色改变。
如何实现?

解决方案 »

  1.   

    没有吗?
    entet 不是吗?
      

  2.   

    <HTML>
    <HEAD>
    <SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
    <!--
    function text1_onfocus() {
      window.text1.style.backgroundColor = "#ff0000";
    }
    //-->
    </SCRIPT>
    </HEAD>
    <BODY><P><INPUT id=text1 name=text1 LANGUAGE=javascript onfocus="return text1_onfocus()"></P></BODY>
    </HTML>
      

  3.   

    <asp:TextBox id=txt_Test runat=Server></asp:TextBox>在后台代码里
    if(!Page.IsPostBack)
    {
       txt_Test.Attribute.Add("onfocus","return text1_onfocus()")
    }
      

  4.   

    对,用楼上的,onfocus是用户端事件
      

  5.   

    this.TextBox1.Attributes.Add("onblue","document.getElementById('Label ID').Style.backgroundColor='#336699';");
      

  6.   

    这样写:
    Me.TextBox1.Attributes.Add("onfocus", "window.Label1.style.backgroundColor ='#336699';")C#this.TextBox1.Attributes.add("onfocus", "window.Label1.style.backgroundColor='#336699';");
      

  7.   

    我上面写的不成吗?我试过,可以的.TextBox1就是文本框了.
    Label1就是标签啊.
      

  8.   

    this.TextBox1.Attributes.add("onfocus", "window.Label1.style.backgroundColor='#336699';");这个可以
      

  9.   

    离开那就是onblue了.this.TextBox1.Attributes.add("onblue", "window.Label1.style.backgroundColor='#000000';");
      

  10.   

    我买了一个 便宜的 asp.net空间!才50元!高兴!给分!!
    100mb 的!可以做论坛!才 50元!!速度飞快!
    www.hi876.com 你们看看
      

  11.   

    怎么不行?
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    '在此处放置初始化页的用户代码
    Me.TextBox1.Attributes.Add("onfocus", "window.Label1.style.backgroundColor ='#336699';")
    '获得焦点
    Me.TextBox1.Attributes.Add("onblur", "window.Label1.style.backgroundColor ='#ff0000';")
    '失去焦点
    End Sub在我这儿可以正常运行的.你有什么错误吗?
      

  12.   

    把以下代码复制运行.
    private void Page_Load(object sender, System.EventArgs e) 

     this.TextBox1.Attributes.Add("onfocus", "window.Label1.style.backgroundColor ='#336699';"); 
     this.TextBox1.Attributes.Add("onblur", "window.Label1.style.backgroundColor ='#ff0000';"); 
    }
      

  13.   

    renyu732(在学.net中...) (
    大侠现在好了.再请教一下:
    如果我想让标签上的文字改变.
    在Add("","这里应该如何写呢.同时色彩也想变化.")