2011-12-27 34 views
0

我一直习惯使用标准Asp.net旁边的控件AjaxControlToolkit并从未遇到过问题。最近我不得不使用Dundas Charting这些控件不是标准的.NET控件,我必须根据Dundas中显示的报告控制apage的一部分。如何更改asp UpdatePanel的标准事件处理程序签名?

不幸的是邓达斯事件签名不通过的UpdatePanel和的iget以下错误认识

说明:

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. 

所以我想知道那有可能改变处理程序忽略updatepanel?如果是的话,该怎么做?

+0

IMO,事件签名是什么样的?标准事件签名意味着'void'返回类型和两个参数 - 对象(发送者)和事件参数(派生自'EventArgs'的类型)。我觉得登打士不太可能有不同的签名 - 也许问题在别的地方。 – VinayC 2011-12-27 08:55:50

回答

1

它看起来好像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); 
     } 
    } 
} 
+0

良好的提示队友,但'CommandFiredEventArgs'被dundas加密 – 2011-12-27 09:13:36

+1

我并不是建议你从Dundas事件参数派生。您需要自己创建一个新的EventArgs类,从System.EventArgs派生并添加到Dundas需要的任何内容中。然后,在启动自定义事件时,您需要将Dundas CommandFiredEventArgs映射到CustomCommandFiredEventArgs。显然,如果你不需要任何信息,你可以使用EventArgs.Empty创建签名(object,EventArgs)并触发事件。 – starskythehutch 2011-12-27 09:20:54

+0

哇,听起来很实用。感谢您的描述 – 2011-12-27 09:22:50

相关问题