asp.net - 如何更改 asp Updatepanel 的标准事件处理程序签名?

标签 asp.net .net ajax error-handling ajaxcontroltoolkit

我一直习惯使用标准 ASP.NET 旁边的控件AjaxControlToolkit 并且从未遇到过问题。最近我不得不使用 登打士图表 不是标准 .NET 控件的控件,我必须根据 中显示的报告来控制页面的一部分邓达斯 .

不幸的是,UpdatePanel 无法识别 Dundas 事件签名,并且出现以下错误

描述:

 An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

异常详情:
 System.InvalidOperationException: The 'CommandFired' event on associated control 'chart1' for the trigger in UpdatePanel 'updatepanel1' does not match the standard event handler signature.

所以我想知道是否有可能更改更新面板的处理程序签名?如果是,该怎么做?

最佳答案

看起来好像 CommandFiredEventArgs类不是从 System.EventArgs 派生的这可能是问题所在。我不会尝试更改 UpdatePanel 期望的签名,而是从 Chart 对象派生一个子类,然后添加您自己的事件,并将您自己的 EventArgs 类作为签名的一部分。然后应该很容易将这些与现有的 Dundas 事件联系起来。

一个非常粗略的示例,无法访问下面的 VisualStudio。这还没有编译,所以请自己整理一下,但它概述了总体思路。

public class CustomChart : Dundas.Charting.WebControl.Chart
{
     public event EventHandler<EventArgs> MyCustomEvent;

     public CustomChart()
     {
          this.CommandFired += SomeMethod;
     }

     private void SomeMethod(object sender, CommandFiredEventHandler args)
     {
          this.OnMyCustomEvent(EventArgs.Empty);
     }

     protected void OnMyCustomEvent(EventArgs args)
     {
         if (this.MyCustomEvent != null)
         {
              this.MyCustomEvent(this, args);
         }
     }
}

关于asp.net - 如何更改 asp Updatepanel 的标准事件处理程序签名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8642457/

相关文章:

c# - 迭代和修改字典

asp.net - 没有 JavaScript 的谷歌分析

c# - 以编程方式选中 DataGridView 中的复选框

c# - 有没有办法在 C# 中获取内部类列表?

javascript - 开发运营 REST API : can not update work item status using PATCH method

javascript - 为什么我的文本框没有用查询结果更新

html - 无法加载所有资源 - 错误 500

c# - Asp.net mvc 应用程序中 Layout 和局部 View 的比较

c# - 启用迁移-ContextTypeName 错误 : Cannot find parameter

java - Jquery无法向servlet发送请求错误404未找到