ASP.NET按钮不开火click事件 [英] ASP.NET button not firing on click event

查看:116
本文介绍了ASP.NET按钮不开火click事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来Asp.net和我的问题可能不那么专业。我使用的 Udemy.com 的设计在我的asp.net web表单的项目。我把标题和 udemy 的页脚在母版。但是,当我加入一个按钮的m个Web窗体的Click事件不会触发。

I am new to Asp.net and my question may not be so professional. I am using the design of Udemy.com in my asp.net web forms project. I put the header and footer of udemy in a masterpage. But when I add a button to one of m web forms the click event will not fire.

<asp:Button ID="Button1" runat="server" onclick="Button1_Click1" Text="Button" />

protected void Button1_Click1(object sender, EventArgs e)
{
    Page.Title = "Sample Text";
}

要解决这个问题,我删除了所有的脚本,从我的网页。我也尝试设置的CausesValidation 为False。但没有什么帮助。
你能帮我解决这个问题?

To fix this problem, I deleted all of the scripts from my pages. Also I tried to set CausesValidation to False. But nothing helps. Could you help me fix this problem?

我添加了onclick事件我的code。但是,我仍然面临这个问题。

I added the OnClick event to my code. But I still face that problem.

推荐答案

的几点,你可以尝试......你贴(更新后)的code应该工作。

Some points you may try... The code that you posted (after update) should work.


  • 如果您在按钮打开你的Visual Studio的设计部分,双击,这将导致你到该按钮的情况下点击,如果没有一个事件,然后它会为您创建一个。

  • 您的按钮的形式必须是标签内。

  • 要测试事件点击射击时,使用断点标签没有或任何其他标​​记的变化,但如果你想它... ...你应该检查标题组件有 =服务器属性,它是一个更新面板内。

  • If you open the Design part of your visual studio and double click in the button, This will lead you to the event click of that button, if there is not one event, then it'll create one for you.
  • Your button must be within the form tag.
  • To test the event click is firing, use Breakpoints not label or any other markup change, but if you want it ... you should check if the Title component has runat="server" attribute and it's within an update panel.

这篇关于ASP.NET按钮不开火click事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆