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

Window attributes lost when shown twice

5 Answers 75 Views
Window
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 21 Feb 2014, 02:54 PM
Hi, I have a RadWindowManager defined like this:
 
           <telerik:RadWindowManager VisibleStatusbar="false" VisibleTitlebar="false" BorderStyle="Double" BorderWidth="100" BorderColor="Red"
                                      EnableShadow="false" Behaviors="Close, Move" ID="RadWindowManager" DestroyOnClose="true" ShowContentDuringLoad="true"
                                      RestrictionZoneID ="RestrictionZone" Opacity="85" runat="server" KeepInScreenBounds="true" Modal="true" OnClientClose="ClientClose">
                <Windows>
                    <telerik:RadWindow runat="server" ID="RadWindowUser" Width="400" Height="500" />
                    <telerik:RadWindow runat="server" ID="RadWindowPCN" Width="600" Height="500" />
                </Windows>
            </telerik:RadWindowManager>

...and I'm invoking the two windows separately like this:

            function ShowUserWindow(userId)
            {
                var manager = window.radopen("UserAudit.aspx?id=" + userId, "RadWindowUser");
                return false;
            }
            function ShowPCNWindow(representationId)
            {
                var manager = window.radopen("PCNAudit.aspx?id=" + representationId, "RadWindowPCN");
                return false;
            }

The first time either of the windows is shown it's all fine, with the width and height being correct. But if I then close the window and show the same one again, the width and height are both 300. Any idea what I'm doing wrong here? Thanks.


















5 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 24 Feb 2014, 04:29 PM
Hello John,

This is explained here: http://www.telerik.com/help/aspnet-ajax/window-troubleshooting-common.html - see the Once a RadWindow is closed, it “loses” all its settings (width, height, modality, etc.) section.

Put simply, you need to
- either prevent these RadWIndows from destroying when closed  and one way is to do it like this:
<Windows>
     <telerik:RadWindow runat="server" ID="RadWindowUser" Width="400" Height="500" DestroyOnClose="false" />
     <telerik:RadWindow runat="server" ID="RadWindowPCN" Width="600" Height="500" DestroyOnClose="false" />
 </Windows>

- OR, set the needed properties each time you show them. WIdth and height and position can be set in the radopen statement: http://www.telerik.com/help/aspnet-ajax/window-programming-opening.html. You can use the control's Client-side API to set other properties you need after calling radopen: http://www.telerik.com/help/aspnet-ajax/window-programming-radwindow-methods.html. Note that radopen() returns a reference to the RadWindow, not to the manager.

Regards,
Marin Bratanov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
0
John
Top achievements
Rank 1
answered on 24 Feb 2014, 05:16 PM
Hi Marin,

Many thanks for your reply.

I tried setSize() and center() and they work fine.

All the best,
John
0
Daniel
Top achievements
Rank 1
answered on 30 Apr 2015, 08:54 AM

I have a similar problem...

I have a radwindow on a page... when I open it the first time, sizing, position and content are as expected.

If I cancel (which triggers a window close) then reopen the window... all is expcted EXCEPT it is no lobger modal.  

The events are always called by a ScriptManager wired up to the buttons... and to get them to open, I had to include Sys.Application.add_load  

 

Here is the open statement below:

 ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "OpenNewTask", "<script type='text/javascript'>Sys.Application.add_load(OpenTaskEditor);</script>", false);

 

Here are the funtions to open & close

 function OpenTaskCatalog() {
            var oWnd = $find('<%= TaskCatalogWindow.ClientID %>');
            if (oWnd) {
                oWnd.setSize(setPopW(1100), setPopH(800));
                oWnd.set_enableShadow(true);
                oWnd.set_reloadOnShow(false);
                oWnd.set_showContentDuringLoad(false);
                oWnd.set_modal(true);
                oWnd.set_visibleStatusbar(false);
                oWnd.set_visibleTitlebar(false);
                oWnd.show();
            }
        }
        function CloseTaskCatalog() {
            var oWnd = $find('<%= TaskCatalogWindow.ClientID %>');
            if (oWnd) {
                oWnd.close();
            }

        }

 

Here is the window markup

 

<telerik:RadWindow ID="TaskCatalogWindow" runat="server" Behaviors="Move, Resize, Close" CenterIfModal="true">
    <ContentTemplate>
        <div class="EditorContainer">
            <uc3:TaskCatalog ID="ucTaskCatalog" runat="server" />
        </div>
    </ContentTemplate>
</telerik:RadWindow>

 

 

Thanksin advance

 

0
Marin Bratanov
Telerik team
answered on 30 Apr 2015, 09:50 AM

Hello Daniel,

Try calling the show() method before the others that modify the popup (like set_modal() or setSize().

Also, the OpenTaskEditor function called from the server code does not exist in this code snippet, a function named OpenTaskCatalog exists.

Here is the code that works fine for me:

<telerik:RadWindow ID="TaskCatalogWindow" runat="server" Behaviors="Move, Resize, Close" CenterIfModal="true">
    <ContentTemplate>
        <div class="EditorContainer">
            <%--<uc3:taskcatalog id="ucTaskCatalog" runat="server" />--%>
            <asp:Label ID="Label1" Text="task catalogue control" runat="server" />
            <asp:Button ID="Button2" Text="close WND" OnClientClick="CloseTaskCatalog(); return false;" runat="server" />
        </div>
    </ContentTemplate>
</telerik:RadWindow>
<asp:Button ID="Button1" Text="open WND" OnClick="Button1_Click" runat="server" />
<script>
    function OpenTaskCatalog() {
        var oWnd = $find('<%= TaskCatalogWindow.ClientID %>');
        if (oWnd) {
            oWnd.set_enableShadow(true);
            oWnd.set_reloadOnShow(false);
            oWnd.set_showContentDuringLoad(false);
            oWnd.set_visibleStatusbar(false);
            oWnd.set_visibleTitlebar(false);
            oWnd.show();
            oWnd.setSize(1100, 800);
            oWnd.set_modal(true);
        }
        Sys.Application.remove_load(OpenTaskCatalog);
    }
    function CloseTaskCatalog() {
        var oWnd = $find('<%= TaskCatalogWindow.ClientID %>');
        if (oWnd) {
            oWnd.close();
        }
    }
</script>

protected void Button1_Click(object sender, EventArgs e)
{
     ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "OpenNewTask", "<script type='text/javascript'>Sys.Application.add_load(OpenTaskCatalog);</script>", false);
}


Regards,

Marin Bratanov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Daniel
Top achievements
Rank 1
answered on 30 Apr 2015, 10:16 AM

Thanks for the quick reply Marin...

First, as far the function... I simply copied and pasted the incorrect function... it does exits... and they are nearly identical, just different buttons/windows... but common structure and issue...

I tried re-ordering as you suggested to no avail... HOWEVER... I noted that you added  Sys.Application.remove_load(OpenTaskCatalog);

 I do not have this in my function... adding it solved my issue...  I can even leave the order of calls intact.  I clearly need to do a little more reading on Sys.Application... and add remove_load() to my functions called using it.... 

 Thanks again....

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