Javascript 和 ASP.NET 与 Visual Studio OnMouseOver 控件验证错误
我刚刚开始使用 Javascript,在 Visual Studio 中遇到了一个错误,指出“验证 (ASP.Net):属性‘onMouseOver’不是元素‘Button’的有效属性”。 基本上,我在按钮控件的 HTML 代码中输入了 onMouseOver="this.style.color='Red'" 。 当我运行我的网络项目时,鼠标悬停命令工作得很好; 但是,错误消息已发布。
我应该如何解决此错误,或者此错误消息并不重要,因为鼠标悬停命令效果很好?
谢谢你,
东风公司
I just started working with Javascript and I ran into an error with Visual Studio stating, "Validation (ASP.Net): Attribute 'onMouseOver' is not a valid attribute of element 'Button'". Basically, I entered onMouseOver="this.style.color='Red'" within the HTML code of a button control. When I run my web project, the mouse over command works just fine; however, the error message is posted.
What should I do to resolve this error or is this error message not critical, since the mouse over command works well?
Thank you,
DFM
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Visual Studio 不喜欢
服务器控件标记中的 javascript。 他们的首选方法是在代码隐藏中连接 javascript,例如使用ClientScript.RegisterStartupScript
。 这里有一篇MSDN 文章解释了他们的官方方法。我相信这样做的目的可能是为了让 ASP.Net 能够呈现特定于浏览器的代码。
但是嘿,如果你的代码有效......
Visual Studio does not like javascript within
<asp:..>
server control tags. Their preferred approach is to wire up the javascript in code-behind, for example by usingClientScript.RegisterStartupScript
. Here's an MSDN article explaining their official approach.I believe that the purpose for doing it this way may be so that ASP.Net can render browser-specific code.
But hey, if your code works.......