This is a migrated thread and some comments may be shown as answers.

Cannot Closing RadWindow with async PostBack, help!

1 Answer 90 Views
Window
This is a migrated thread and some comments may be shown as answers.
Alessio
Top achievements
Rank 1
Alessio asked on 21 Jul 2011, 09:09 PM
Hi To everyone,

I am developing a radWindow with a new Page that contains a RadMenu and I want to close it server side with a Button of the RadMenu.
If I use a Full Postback (without using the RadAjaxManager) it works, but when I put the control into the RadAjaxManager the window remains open.

Working Example:
[Javascript]
function GetRadWindow() {
          var oWindow = null;
          if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog
          else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; //IE (and Moz az well)
          return oWindow;
      }
[RadAjaxManager Empty]
<telerik:RadAjaxManagerProxy runat="server" ID="RadAjaxManagerProxy1">
          <AjaxSettings>
          </AjaxSettings>
      </telerik:RadAjaxManagerProxy>

[Server Side]
lblClose.Text = "<script type='text/javascript'>GetRadWindow().Close()</script>";

NB. All the controls is contained in a Panel named "pnlFull".
If I put the panelFull Events in the RadAjaxManager Control, the window will not disappear after the Click on the RadMenu.
Eg.:
<telerik:RadAjaxManagerProxy runat="server" ID="RadAjaxManagerProxy2">
         <AjaxSettings>
             <telerik:AjaxSetting AjaxControlID="pnlFull">
                 <UpdatedControls>
                     <telerik:AjaxUpdatedControl ControlID="pnlFull" LoadingPanelID="MasterLoadingPanelBig" />
                 </UpdatedControls>
             </telerik:AjaxSetting>
         </AjaxSettings>
     </telerik:RadAjaxManagerProxy>

Someone can help me????

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 26 Jul 2011, 03:12 PM
Hi Alessio,

This issue is a general case when AJAX is used. In such a scenario I would recommend that you inject the sctipt via the static ScriptManager instance instead of putting it in a label or literal. More information on the matter is available in the following help article: http://www.telerik.com/help/aspnet-ajax/radwindow-troubleshooting-javascript-from-server-side.html. This is your code, modified and working correctly on my end: 
<telerik:RadAjaxManager runat="server" ID="RadAjaxManager2">
         <AjaxSettings>
             <telerik:AjaxSetting AjaxControlID="pnlFull">
                 <UpdatedControls>
                     <telerik:AjaxUpdatedControl ControlID="pnlFull" LoadingPanelID="MasterLoadingPanelBig" />
                 </UpdatedControls>
             </telerik:AjaxSetting>
         </AjaxSettings>
     </telerik:RadAjaxManager>
    <asp:Panel ID="pnlFull" runat="server">
    <telerik:RadMenu runat="server" ID="RadMenu1" OnItemClick="OnItemClick">
        <Items>
            <telerik:RadMenuItem runat="server" id="RadMenuItem1" Text="close RadWindow"></telerik:RadMenuItem>
        </Items>
    </telerik:RadMenu>
    </asp:Panel>
    <script type="text/javascript">
        function GetRadWindow()
        {
            var oWindow = null;
            if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog
            else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; //IE (and Moz az well)
            return oWindow;
        }
    </script>

and:
protected void OnItemClick(object sender, Telerik.Web.UI.RadMenuEventArgs e)
{
    string script = "GetRadWindow().close();";
    ScriptManager.RegisterStartupScript(this, this.GetType(), "key", script, true);
}
Please note that I am using the regular RadAjaxManager, as I do not have your custom setup, but this is not relevant to the way the script should be injected.

 

Kind regards,
Marin
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Window
Asked by
Alessio
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or