asp.net:监控用户点击
我试图在用户单击超链接时触发事件。但它会抱怨该事件未定义:
<asp:HyperLink ID="HyperLink1" onmouseover="btnSubmit_Click" runat="server">www.google.com</asp:HyperLink>
<asp:Button
id="btnSubmit"
Text="Submit"
Runat="server" />
protected void btnSubmit_Click(object sender, EventArgs e)
{
btnSubmit.Text = "clicked a link!!!";
}
I'm trying to fire an event when a user clicks a hyperlink. But it would complain that the event is not defined:
<asp:HyperLink ID="HyperLink1" onmouseover="btnSubmit_Click" runat="server">www.google.com</asp:HyperLink>
<asp:Button
id="btnSubmit"
Text="Submit"
Runat="server" />
protected void btnSubmit_Click(object sender, EventArgs e)
{
btnSubmit.Text = "clicked a link!!!";
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我看到几个问题。
您能提供更多关于您正在尝试做的事情的细节吗?我假设您发布的 C# 代码位于后面的代码中?
更新:
尝试将您的代码更改为此 -
显然这不会重定向您,但根据您的代码的作用,听起来您并不想要重定向...
I see several problems.
Can you provide more detail of what you are trying to do? I assume the c# code you have posted resides in the code behind?
Update:
Try changing your code to this -
Obviously this will not redirect you, but based on what your code does, it doesn't sound like you want a redirect...
您尝试触发的事件是服务器端事件。您需要使用客户端代码来完成您想做的事情。另外,没有称为 onmouseover 的属性,您可以从后面的代码将其添加为客户端事件
The event you're trying to trigger is a server side event. You need to use client side code for what you want to do. Plus, there is no property known as onmouseover, you can add it as a client side event from code behind