开发者

Problem with ajax and RadTreeView

Hi all : I have a user control which contain RadTreeView from Telerik inside ModalPopupExtender , the previous control loaded at runtime :

DashBoardDesignerCell tempCell = LoadControl("~/UserControls/DashBoardDesignerControls/DashboardDesignerCell.ascx") as DashBoardDesignerCell;

When SelectedNodeChanged occurs the ModalPopupExtender disappears.

This is the full code for user contrl:

<%@ 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">
                                                    &nbsp;
                                                </td>
                                                <td class="popup_header_right">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="popup_main_left">
                                                    &nbsp;
                                                </td>
                                                <td class="popup_main">
                                                    &nbsp;
                                                    <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="okButto开发者_Python百科n" 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">
                                                    &nbsp;
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="popup_footer_left">
                                                </td>
                                                <td class="popup_footer_middle">
                                                    &nbsp;
                                                </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();
            }
        }

Is There any idea???


Do you by any means do postback or ajax request when a treeview node is selected? This might be potential cause the modal popup extender is closed. Why you do not use the Telerik Ajax window instead, to compare the results? Also I assume that you load the user control dynamically on init or load of the page and clear the Controls collection of the container before adding the user control inside it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜