onclick 无法执行任何操作
C#
protected void btnSubmit_Click(object sender, ImageClickEventArgs e)
{
//I want to do something here as simple as this below with onClick
label1.Text = "hi";
}
ASP.NET
<asp:ImageButton id="OBBtn_Save" runat="server" OnClick="btnSubmit_Click"
ImageUrl="images/buttons/submit.gif"/>
C#
protected void btnSubmit_Click(object sender, ImageClickEventArgs e)
{
//I want to do something here as simple as this below with onClick
label1.Text = "hi";
}
ASP.NET
<asp:ImageButton id="OBBtn_Save" runat="server" OnClick="btnSubmit_Click"
ImageUrl="images/buttons/submit.gif"/>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用简单的 html 控件:
You could use simple html controls:
检查 aspx 文件中的 page 指令,验证代码隐藏文件是否指向正确的文件,并且它继承的类也正确。
大写字母很重要。
另一种可能是dll文件错误也是解决办法。
清理解决方案然后重建。
如果您想确保事件已连接,
您所要做的就是 += OnInit 方法中的事件处理程序。然后你就确定它被创建了。
缺点是如果您这样做,您还需要 -= OnUnload 方法中的事件处理程序以防止内存泄漏。
但至少电线可以工作。它是在代码中的,所以如果有时间你可以找到它的所有参考资料。
check the page directive in the aspx file, verify that the codebehind file is pointing to the right file, and that the class that it inherits is also correct.
Capitalization is important.
another possibility is the wrong dll files is the solution.
Clean the solution then rebuild.
If you want to make sure the event is wired,
all you have to do is += the Event handler in the OnInit method. Then you are sure it was created.
the Downside is if you do this you will also need to -= the event handler in the OnUnload method to prevent memory leaks.
But at least the wire works. and Its in code so you can find all references on it should the time arise.
页面中有验证器吗?这可能很简单,因为您的页面由于验证错误而根本没有发布。我知道我过去曾经这样做过。
Do you have any validators in the page? It could be as simple as your page not posting at all because of a validation error. I know I've done it before in the past.