关于修改文本框的背景色

liuxn2003 liuxn2003 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
怎样才能在 *.aspx.vb 中写一个sub,在page_load中调用,使得界面上的所有可输入框在获得焦点时背景色发生变化。我试着用for each ... in,但是没有效果。(界面上用的是web控件)

this is my source code:

Private Sub SetColor()

'Dim txtCtrl As System.Web.UI.Control
Dim txtCtrl As Object

For Each txtCtrl In Me.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

End Sub
...全文
评论 9
收藏 已收藏
分享
返回顶部
liuxn2003
.NET社区 62,272 成员 668,968 内容