我在我的 ASP.NET 应用程序中使用动态控件。所以问题是——当我单独使用这些控件时——它们运行良好。但是当我将这两个控件放在同一页面上时 - 只有最后一个提交事件被触发。谁能帮我确定问题出在哪里以及如何解决?
这是我的 aspx 布局:
<%@ Control Language="C#" AutoEventWireup="True" CodeBehind="MYPAGE.ascx.cs" Inherits="MYNAMESPACE" %>
<%@ Register Assembly="MYANOTHERNAMESPACE" Namespace="MYNAMESPACE" TagPrefix="DAControl" %>
...
<div>
<DAControl:ChooseImageDialog runat="server" id="ChooseImageDialog" />
<DAControl:ChooseVideoDialog runat="server" id="ChooseVideoDialog" />
</div>
这是我的第一个控件:
[ToolboxData("<{0}:ChooseImageDialog runat=server></{0}:ChooseImageDialog>")]
public class ChooseImageDialog : WebControl
{
/* This is only part of my code, which should enough for explaining the issue*/
private Button applyPreview = new Button();
private Button cancelPreview = new Button();
protected override void OnLoad(EventArgs e)
{
applyPreview.Click += new EventHandler(applyPreview_Click);
base.OnLoad(e);
}
void applyPreview_Click(object sender, EventArgs e)
{
// I want to reach this block
}
}
}
这是我的第二个控制:
[ToolboxData("<{0}:ChooseVideoDialog runat=server></{0}:ChooseVideoDialog>")]
public class ChooseVideoDialog : WebControl
{
/* This is only part of my code, which should enough for explaining the issue*/
private Button applyVideoPreview = new Button();
private Button cancelPreview = new Button();
protected override void OnLoad(EventArgs e)
{
applyVideoPreview.Click += new EventHandler(ApplyPreviewVideo_Click);
base.OnLoad(e);
}
void ApplyPreviewVideo_Click(object sender, EventArgs e)
{
// I want to reach this block
}
}