樣式定義
採用htc可以達到效果

解决方案 »

  1.   

    应该是判断条件有错误你查看页面的源文件,看看有没有添加了”onfocus“的属性或者设置断点看判断语句有没有执行
      

  2.   

    我发现Me.Controls返回的并不是界面上所有控件的集合,我的界面上有输入项目30多项,而Me.Controls.Count却只是3,我很困惑!
      

  3.   

    最好是直接使用ID添加属性!
    Me.Controls应该应该是页面下的控件个数,不包括控件下的子控件,如果一定要用循环,你可以试一试用递归的方法添加控件属性
      

  4.   

    把所有的TextBox 放入placeholder中 然后再用 For Each txtCtrl In ph1.Controls
                If TypeOf txtCtrl Is TextBox Then
                    txtCtrl.Attributes.Add("onfocus", "this.style.backgroundColor='#ffffc0';")
                    txtCtrl.Attributes.Add("onblur", "this.style.backgroundColor='#ffffff';")
                End If
            Next txtCtrl
      

  5.   

    把所有的TextBox 放入placeholder中 然后再用 For Each txtCtrl In ph1.Controls
                If TypeOf txtCtrl Is TextBox Then
                    txtCtrl.Attributes.Add("onfocus", "this.style.backgroundColor='#ffffc0';")
                    txtCtrl.Attributes.Add("onblur", "this.style.backgroundColor='#ffffff';")
                End If
            Next txtCtrl