我一直习惯使用标准 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/