我在 ModalPopupExtender 中有一个详细信息视图,它运行良好。在详细信息视图的页脚模板部分中,我放置了几个链接按钮。
当按下链接按钮时,它应该触发动态创建的 CollapsiblePanelExtender。到目前为止,一切正常。下面是modalpopup里面detailsview的一部分
<Toolkit:ModalPopupExtender ID="mdlPopup" runat="server" TargetControlID="btnShowPopup"
PopupControlID="pnlPopUp" BackgroundCssClass="modalBackground"
PopupDragHandleControlID="DragHandle" DropShadow="true"/>
<asp:Panel ID="pnlPopUp" runat="server" style="display:none;"
CssClass="popUpStyle">
<asp:Panel ID="DragHandle" runat="server" CssClass="drag" ></asp:Panel>
<asp:DetailsView ID="dvwDetailsUser" runat="server"
AutoGenerateRows="False"
Width="100%"
onitemcommand="dvwDetailsUser_ItemCommand"
FooterStyle-HorizontalAlign="Right"
ForeColor="#990000"
BorderWidth="0px" >
<Fields>
<asp:BoundField DataField="GivenName" HeaderText="First name" />
<asp:BoundField DataField="SurName" HeaderText="Last name" />
<asp:BoundField DataField="DisplayName" HeaderText="DisplayName" />
<asp:BoundField DataField="SamAccountName" HeaderText="Account" />
<asp:BoundField DataField="EmailAddress" HeaderText="E-mail" />
<asp:CheckBoxField DataField="Enabled" HeaderText="user enabled" />
<asp:BoundField NullDisplayText="" />
<asp:BoundField DataField="DistinguishedName"
HeaderText="DistinguishedName" />
</Fields>
<FooterStyle HorizontalAlign="Right" />
<FooterTemplate >
<asp:LinkButton ID="btnProperties"
runat="server" CommandName="Remove" Text="Remove" />
</FooterTemplate>
<HeaderStyle BackColor="#FFCD4A" Font-Bold="True"
HorizontalAlign="left" />
<AlternatingRowStyle BackColor="#EFEFEF" />
</asp:DetailsView>
</asp:Panel>
modalpopup 扩展器和详细信息视图包含在更新面板中。当我在弹出窗口中按下链接按钮时,将显示可折叠面板。
在可折叠面板内,我还动态创建了按钮。当我按下按钮时,不会触发附加到按钮的新事件处理程序。
protected void dvwDetailsUser_ItemCommand(object sender, DetailsViewCommandEventArgs e)
{
if (e.CommandName == "Remove")
DeleteAccount();
end if
}
public void DeleteAccount()
{
Panel p = new Panel();
Button btnRemove = new Button();
p.ID = "pnlDeleteAccount";
p.GroupingText = "Remove" + dvwDetailsUser.Rows[2].Cells[1].Text;
btnRemove.Text = "Remove"
btnRemove.ID = "Apply";
btnRemove.CausesValidation = false;
btnRemove.UseSubmitBehavior = false;
btnRemove.Click += new EventHandler(btnRemove_Click);
p.Controls.Add(btnRemove);
CollapsiblePanelExtender cpe = new CollapsiblePanelExtender();
cpe.TargetControlID = p.UniqueID;
cpe.ExpandControlID = p.UniqueID;
cpe.CollapseControlID = p.UniqueID;
cpe.AutoCollapse = false;
cpe.AutoExpand = false;
cpe.ScrollContents = false;
cpe.SuppressPostBack = false;
cpe.ExpandDirection = CollapsiblePanelExpandDirection.Vertical;
cpe.Page = this.Page;
pnlPopUp.Controls.Add(cpe);
cpe.Controls.Add(p);
mdlPopup.Show();
}
public void btnRemove_Click(object sender, EventArgs e)
{
Response.Redirect("UserAccount.aspx");
}
我放置了一个 response.redirect 以查看按下删除按钮时是否会触发事件 btnRemove_click。
我在这里错过了什么吗?