为以编程方式创建的文本框设置 onblur 和 onfocus 属性?
如何将 onblur 和 onfocus 属性放在以编程方式创建的文本框上?
这是我的代码 -
td = New HtmlTableCell
td.Style.Add("padding-bottom", "5px")
Dim txtbox As New TextBox
txtbox.Style.Add("width", "96%")
txtbox.ID = "ename"
td.Controls.Add(txtbox)
tr.Cells.Add(td)
td.Style.Add("padding-top", "5px")
现在我想添加 onblur 和 onfocus。有类似的东西吗? ——
txtbox.attributes.Add("onblur","Enter Name")
txtbox.attributes.Add("onfocus","")
我尝试过这个,但不起作用。有谁知道该怎么做?
How do I put the onblur and onfocus attributes on a textbox created programatically?
Here's my code -
td = New HtmlTableCell
td.Style.Add("padding-bottom", "5px")
Dim txtbox As New TextBox
txtbox.Style.Add("width", "96%")
txtbox.ID = "ename"
td.Controls.Add(txtbox)
tr.Cells.Add(td)
td.Style.Add("padding-top", "5px")
Now I want to add onblur and onfocus. is there something like? --
txtbox.attributes.Add("onblur","Enter Name")
txtbox.attributes.Add("onfocus","")
I tried this and doesn't work. Does anyone know how to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
onblur 和 onfocus 是 JavaScript 事件处理程序。它们的值必须是有效的 JavaScript。您可能正在寻找这样的东西:
onblur and onfocus are JavaScript event handlers. Their values must be valid JavaScript. You're probably looking for something like this: