C# - ASP.NET按钮的Click事件不工作 [英] C# - ASP.NET Button click event not working

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

问题描述

我有一些第三方控件,有些ajaxy的东西,一些正常的ASP.NET按钮控件的ASP.NET(C#)页面。

I have an ASP.NET (C#) page with some 3rd party controls, some ajaxy stuff and some normal ASP.NET Button controls.

单击时按钮的Click事件不会触发。

双击在设计模式按钮,在VS 2008切换到code-落后,但不创建事件处理程序。

Double-clicking the button in design mode in VS 2008 switches to the code-behind but doesn't create the event handler.

创建事件处理程序手动于事无补。

Creating the event handler manually doesn't help.

整个页面太大,包括在这里,但这是最高位:

The whole page is too big to include here, but this is the top bit:

<%@ Page Language="C#" MasterPageFile="~/basewidepage2.master" AutoEventWireup="true" EnableEventValidation="false" CodeFile="CompanyCompliance.aspx.cs" Inherits="CompanyCompliancePage" Title="3DSS" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register Assembly="obout_Grid_NET" Namespace="Obout.Grid" TagPrefix="cc2" %>
<%@ Register Src="usercontrols/CalendarEx.ascx" TagName="CalendarEx" TagPrefix="uc2" %>
<%@ MasterType VirtualPath="~/basewidepage2.master" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceholder1" runat="Server">

    <script type="text/javascript">
         // a bunch of function declarations
    </script>

...并在页面上我的按钮声明:

...and my button declaration on the page:

<asp:Button ID="LicenseCsvButton" runat="server" Text="Export to CSV" OnClick="LicenseCsvButton_Click" />

...和code-背后:

...and the code-behind:

protected void LicenseCsvButton_Click(object sender, EventArgs e)
{
    // get data
    CompanyCompliance cc = new CompanyCompliance(Master.theCompany.ID);
    DataTable dt = cc.BusinessLicenses.Tables[0];

    // send to browser as download
    Tools.SendTableAsCsvToBrowser(Response, dt, "LicenseData");
}

任何想法?难道是阿贾克斯还是什么?也许第三方obout网格控件?

Any ideas? could it be the ajax or something? Maybe the 3rd party "obout" grid control?

更新:结果
我没有解决这个问题一两个月前,等我回来对这个问题回答它为后人但无法记得正是我的固定它! (诅咒你,晚年!)我通过更换一些ASP.NET AJAX的有一些有限的成功与jQuery UI的人控制,但我认为真正的解决办法是,在标签的一个属性之一是指向控制不再存在了。

Update:
I did fix this a month or two ago, so I came back to this question to answer it for posterity but couldn't remember exactly how I fixed it! (Curse you, old age!) I had some limited success by replacing some of the ASP.NET AJAX controls with jQuery UI ones but I think the real solution was that one of the properties in the one of the tags was pointing to a control that no longer existed.

如果你在这个同样的情况是,尝试让我在评论中知道什么可行,我会发布了正确的答案。

If you're in this same situation, try that and let me know what works in the comments and I'll post the correct answer.

推荐答案

在调试过程中,检查按钮的CausesValidation属性。出于某种原因,我的一个网页有一个按钮,默认为真。当我明确地将其设置为假一切正常。

During debugging, check the CausesValidation property of your button. For some reason, one of my pages had a button defaulting to "True." When I explicitly set it to "False" everything worked.

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

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