我在ModalPopupExtender中有一个详细信息视图,它可以很好地工作。 在详细信息视图的footertemplate部分中,我放置了几个链接按钮。
当按下linkbutton时,它应该触发一个动态创建的CollapsiblePanelExtender。到目前为止,一切都按预期工作。以下是modalpopup
中详细信息视图的一部分<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扩展程序和详细信息视图包含在updatepanel中。 当我在弹出窗口内按下一个链接按钮时,将显示可折叠面板。
在collapsiblepanel内部,我还有动态创建的按钮。当我按下按钮时,不会触发连接到按钮的新事件处理程序。
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。
我在这里错过了什么吗?