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

RadWindowManager's DestroyOnClose="True" not working?

4 Answers 327 Views
Window
This is a migrated thread and some comments may be shown as answers.
dave
Top achievements
Rank 1
dave asked on 24 Jan 2011, 04:35 PM
Hi

We have recently updated a web application which was using Telerik.Web.UI version 2008.3.1314.35 to and updated the to version 2010.3.1317.35. 

The application sets the RadWindowManager's DestroyOnClose="True" and opens a window using server side code. Before I updated when window's close button is clicked, the window closes and the RadWindowManager to deletes the window.  
After update to version 2010.3.1317.35 the window closes but is not deleted and when the page posts back the window reappears.

An example of the mark up I use is
<body>
    <form id="form1" runat="server">
     <telerik:RadScriptManager ID="QMAS2ScriptManager" runat="server" EnableTheming="True">
    </telerik:RadScriptManager>
    <telerik:RadWindowManager ID="DialogWindowManager" runat="server" 
        Modal="True" Overlay="True" VisibleStatusbar="False" ReloadOnShow="True" 
        ShowContentDuringLoad="False"
        KeepInScreenBounds="True" 
        Behaviors="Resize, Close, Maximize, Move, Reload" 
        OnClientClose="OnClientClose"
        DestroyOnClose="True"
        Height="500px" Width="650px" Behavior="Resize, Close, Maximize, Move, Reload"
        InitialBehavior="None" Left="" Style="display: none;" Top="">
    </telerik:RadWindowManager>
    <div>
       <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
    </div>
    <script type="text/javascript">
        function OnClientClose(radWindow) 
        {
           __doPostBack();
        }
    </script>
    </form>
</body>

the code I use to create a new window looks like 

       protected void Button1_Click(object sender, EventArgs e)
        {
            RadWindowManager rwm = this.DialogWindowManager;
            RadWindow newWindow = new RadWindow();
            newWindow.NavigateUrl = "wwww.google.co.uk"; // url;//  +"?sessionPrefix=" + sessionPrefix + additionalQueryStringParams;
            newWindow.Title = "Test";
            newWindow.VisibleOnPageLoad = true;
            rwm.Height = 400;
            rwm.Width = 400;
            rwm.Windows.Add(newWindow);
        }

Any idea why this is happening?


4 Answers, 1 is accepted

Sort by
0
dave
Top achievements
Rank 1
answered on 24 Jan 2011, 04:47 PM
Ah after posting i realised that it the way the rad manager handles view state has changed
all it need is 
EnableViewState="false" 
:-)
0
Martin
Top achievements
Rank 1
answered on 01 Feb 2012, 07:39 AM
I have the same problem - I create windows on the server side and have DestroyOnClose='true". I found that the windows does get deleted on the client side, but that deletion doesn 't get persisted to the server side. So I set "EnableViewState="false" and it changes the behavior 9in that the window does now disappear. But it also disappears if I create a SECOND window.
So my scenario is this:

I create a Window - then I minimize it. Then, on the server side, I create a new Window so now I have two open, but with EnableViewState set to false, the first window disappears. It appears that I need some tracking and commit function on the client side to post back the updated Windows array on postback.

Any ideas?

0
Martin
Top achievements
Rank 1
answered on 01 Feb 2012, 06:16 PM
When I wrote that post last night, I mistakenly read the date Jan 24, 2011 as 2012 and assumed it was a recent post. Otherwise I would have started a new thread.

But my problem remains. I have a RadWindowManager with DestroyOnClose='true' but on every postback, even after closing the window theRadWindowManager's Windows collection still contains the window. I do not have VisibleOnPageLoad set. Instead, on every load, I run the following javascript.
function openPromoteWindows(RadWindowManagerId) {
    var oManager = $find(RadWindowManagerId);
    var oWindows = oManager.GetWindows();
    for (i = 0; i < oWindows.length; i++) {
        var oWindow = oWindows[i];
        oWindow.show();
        oWindow.Minimize();
        oWindow.get_popupElement().style.zIndex = 10000 + i;
    }
}

This successfully opens all the windows minimized inside a taskbar. The problem is that since closded windows are still in the Windows Collection, they reappear.

I did write some code called "OnClientClose that does successfully delete the window from the windows collection on the client side, but it doesn't persist. That code is below:

function rwmPromote_Close(sender, eventargs) {
    var rwm = $find(window['rwmPromoteId']);
    var oWindows = rwm.GetWindows();
    var i;
    for (i = 0; i < oWindows.length; i++) {
        var oWindow = oWindows[i];
        if (oWindow == sender)
            break;
    }
    if (i < oWindows.length) {
        rwm._windows.splice(i, 1);
    }
}

This code was added in desperation to try and get the information persisted to the server side. I tried setting EnableViewState to false, but as expected that makes it forget about all Windows in the Windows collection except for ones added during that postback, which means it does forget about closed windows but also forgets about minimized windows.

I am about to add a HiddenField which will contain the ClientIDs of all Windows and then I will use that server side to deduce which windows, if any, were closed. While I am hopeful this will work, I am sure it's not the way it is supposed to work.

Suggestions welcomed!!
0
Martin
Top achievements
Rank 1
answered on 01 Feb 2012, 07:55 PM
I have implemented the HiddenField idea I mentioned in my last post and it works. But it should be possible to get the RawWindowManager to be updated automatically without me having to do silly things, so I am still looking for the correct answer.

Martin
Tags
Window
Asked by
dave
Top achievements
Rank 1
Answers by
dave
Top achievements
Rank 1
Martin
Top achievements
Rank 1
Share this question
or