大家好: 我有一个用户控件,其中包含ModalPopupExtender中来自Telerik的RadTreeView,前一个控件在运行时加载:
DashBoardDesignerCell tempCell = LoadControl("~/UserControls/DashBoardDesignerControls/DashboardDesignerCell.ascx") as DashBoardDesignerCell;
当SelectedNodeChanged发生时,ModalPopupExtender消失。
这是用户控制的完整代码:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="DashBoardDesignerCell.ascx.cs"
Inherits="RightBI.UserControls.DashBoardDesignerControls.DashBoardDesignerCell" %>
<%@ Register Src="~/UserControls/PresentationControls/SelectPresentationControl.ascx" TagPrefix="rightbicontrols" TagName="selectpresentationcontrol" %>
<asp:UpdatePanel ID="dashboardDesignerCellUpdatePanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table cellpadding="3" cellspacing="0" style='width: 100%; border-style: solid; border-width: thin;
border-color: Silver;'>
<thead>
<tr style='background: blue'>
<td>
<asp:ImageButton SkinID="selectControlButton" runat="server" ID="addControlButton"
OnClick="okButton_Click" />
<asp:ImageButton SkinID="deleteControlButton" runat="server" ID="removeControlButton"
OnClick="removeControlButton_Click" />
<asp:LinkButton runat="server" ID="LinkButton1" Style='display: none;'>
</asp:LinkButton>
<ajax:ModalPopupExtender runat="server" TargetControlID="addControlButton" ID="selectPresentationControlModalPopupExtender"
PopupControlID="popupSelectPresentationControl" CancelControlID="cancelButton"
BackgroundCssClass="popup_black_BG">
</ajax:ModalPopupExtender>
<asp:Panel runat="server" ID="popupSelectPresentationControl" Style='display: none;'>
<asp:UpdatePanel runat="server" ID="popupSelectUpdatePanel" UpdateMode="Conditional">
<ContentTemplate>
<div class="popup_container">
<table cellpadding="0" cellspacing="0" class="popup_table">
<tr>
<td class="popup_header_left">
</td>
<td class="popup_header_middle">
</td>
<td class="popup_header_right">
</td>
</tr>
<tr>
<td class="popup_main_left">
</td>
<td class="popup_main">
<div class="popup_content">
<table cellpadding="0" cellspacing="0" style='width: 100%'>
<tr>
<td>
<span>Caption (*):</span>
</td>
<td>
<asp:TextBox runat="server" ID="captionTextBox">
</asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="captionTextBox"
ValidationGroup="SelectPresentationControl" ErrorMessage="Caption is required."
Text="*">
</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td colspan="2">
<rightbicontrols:selectpresentationcontrol id="selectControl" runat="server" />
</td>
</tr>
<tr>
<td colspan="2">
<telerik:RadButton ID="okButton" Text="Save" SkinID="okButton" runat="server" CommandName="Save"
ValidationGroup="SelectPresentationControl" OnClick="okButton_Click">
</telerik:RadButton>
<telerik:RadButton ID="cancelButton" Text="Cancel" SkinID="cancelButton" runat="server"
CommandName="Cancel">
</telerik:RadButton>
</td>
</tr>
</table>
</div>
</td>
<td class="popup_main_right">
</td>
</tr>
<tr>
<td class="popup_footer_left">
</td>
<td class="popup_footer_middle">
</td>
<td class="popup_footer_right">
</td>
</tr>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
</td>
</tr>
</thead>
<tbody>
<tr>
<td style='min-height: 150px;'>
<asp:UpdatePanel runat="server" ID="controlUpdatePanel" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel runat="server" ID="controlPanel">
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
</tbody>
</table>
</ContentTemplate>
</asp:UpdatePanel>
public Guid DashboardColumnID
{
get
{
if (ViewState["DashboardColumnID"] == null)
{
return Guid.Empty;
}
return new Guid(ViewState["DashboardColumnID"].ToString());
}
set
{
ViewState["DashboardColumnID"] = value;
}
}
protected Guid DashboardZoneID
{
get
{
if (ViewState["DashboardZoneID"] == null)
{
return Guid.Empty;
}
return new Guid(ViewState["DashboardZoneID"].ToString());
}
set
{
ViewState["DashboardZoneID"] = value;
}
}
protected Guid PresentationControlID
{
get
{
if (ViewState["PresentationControlID"] == null)
{
return Guid.Empty;
}
return new Guid(ViewState["PresentationControlID"].ToString());
}
set
{
ViewState["PresentationControlID"] = value;
}
}
protected void LoadDashboardZone()
{
DashboardColumn dashboardColumn = DashboardColumn.GetDashboardColumn(DashboardColumnID);
if (dashboardColumn.DashboardZones.Count == 1)
{
DashboardZoneID = dashboardColumn.DashboardZones.FirstOrDefault().Id;
}
if (DashboardZoneID == Guid.Empty)
{
removeControlButton.Visible = false;
addControlButton.Visible = true;
}
else
{
removeControlButton.Visible = true;
addControlButton.Visible = false;
}
controlPanel.Controls.Clear();
if (DashboardZoneID != Guid.Empty)
{
DashboardDesignerZone zone = LoadControl("~/UserControls/DashBoardDesignerControls/DashboardZone.ascx") as DashboardDesignerZone;
zone.DashboardZoneID = DashboardZoneID;
controlPanel.Controls.Add(zone);
}
controlUpdatePanel.Update();
}
protected void Page_Load(Object sender, EventArgs e)
{
//
String code = "function openWindow() {var oWnd = $find('" + selectPresentationWindow .ClientID+ "');oWnd.show(); }";
ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "OpenRadWindow", code , true);
LoadDashboardZone();
}
protected void okButton_Click(object sender, EventArgs e)
{
AddPresentationControl(captionTextBox.Text, selectControl.PresentationControlId);
//dashboardDesignerCellUpdatePanel.Update();
}
protected void removeControlButton_Click(Object sender, EventArgs e)
{
if (DashboardZone.RemoveDashboardZone(this.DashboardZoneID))
{
PresentationControlID = Guid.Empty;
DashboardZoneID = Guid.Empty;
LoadDashboardZone();
//dashboardDesignerCellUpdatePanel.Update();
}
}
public void AddPresentationControl(String caption, Guid presentationControlID)
{
DashboardZone tempDashboardZone = DashboardZone.AddDashboardZone(caption, DashboardColumnID, presentationControlID);
if (tempDashboardZone != null)
{
PresentationControlID = presentationControlID;
DashboardZoneID = tempDashboardZone.Id;
LoadDashboardZone();
}
}
有什么想法???
答案 0 :(得分:0)
在选择树视图节点时,您是否做回发或ajax请求?这可能是因为模态弹出扩展器已关闭。为什么不使用Telerik Ajax窗口来比较结果呢?此外,我假设您在初始化或加载页面时动态加载用户控件,并在其中添加用户控件之前清除容器的Controls集合。