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

all radwindow children reloading when a new one is created

4 Answers 50 Views
Window
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 20 Jan 2014, 02:24 AM
I have a radwindow manager that I am programatically adding windows too. The user may have 5 or 6 open at a time. But when I add a new one using the windows.add method it reloads all the children into the center of the screen one on top of the other. Is there anyway to just add a new window without the children that are already open being touched?

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Jan 2014, 04:46 AM
Hi Mike,

I guess you want to open Multiple RadWindow on same RadWindowManager. Please have a look into the following code snippet which works fine at my end.

ASPX:
<telerik:RadButton ID="Button1" runat="server" Text="OpenNewWindow" OnClick="Button1_Click">
</telerik:RadButton>
<telerik:RadWindowManager ID="RadWindowmanager1" runat="server">
</telerik:RadWindowManager>

C#:
protected void Page_Init(object sender, EventArgs e)
{
    RadWindow win = new RadWindow();
    win.ID = "Win1";
    win.Title = "Window1";
    win.VisibleOnPageLoad = true;
    RadWindowmanager1.Windows.Add(win);
}
protected void Button1_Click(object sender, EventArgs e)
{
    RadWindow win1 = new RadWindow();
    win1.ID = "Win2";
    win1.Title = "Window2";
    win1.VisibleOnPageLoad = true;
    RadWindowmanager1.Windows.Add(win1);
}

Please provide your code if it doesn't help.
Thanks,
Shinu.
0
Mike
Top achievements
Rank 1
answered on 20 Jan 2014, 01:26 PM
Shinu, Thank you for your reply.
However opening multiple windows is not the issue.
Getting the first one to maintain its position and URL is. When you open the second window the first one reloads its contents and repositions itself behind the second one. How do I maintain state on the first window? I don't want it to move or reload.
0
Mike
Top achievements
Rank 1
answered on 20 Jan 2014, 02:10 PM
Here is a small code sample showing the problem.
Each button click loads a new window but all previous windows are reloaded. This is the behavior I wish to avoid.

ASPX
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="Button1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadWindowManager1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server" PreserveClientState="True"></telerik:RadWindowManager>
        <asp:Button ID="Button1" runat="server" Text="Button" />
    
    </div>
    </form>
</body>
</html>

Button Click:
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
       Dim radw As New RadWindow
        radw.ID = System.DateTime.Now.ToString
        radw.NavigateUrl = "http://www.google.com"
        radw.VisibleOnPageLoad = True
        radw.BorderStyle = BorderStyle.None
        radw.BorderWidth = 1
        radw.VisibleTitlebar = True
        radw.Modal = False
        radw.VisibleStatusbar = False
        radw.EnableViewState = True
        radw.ReloadOnShow = False

        radw.Height = 380
        radw.Width = 600
        radw.Title = " Chat Room"

        radw.Behaviors = WindowBehaviors.Move Or WindowBehaviors.Resize

        RadWindowManager1.Windows.Add(radw)
    End Sub
0
Marin Bratanov
Telerik team
answered on 20 Jan 2014, 02:59 PM
Hi guys,

A RadWindow creates its popup with JavaScript, i.e., when it is opened in the browser. Thus, a postback will dispose this HTML and the RadWindow will close. After the postback is received in the browser a new RadWindow will be generated and it will start from the center.
This is the expected behavior with this code.


What I advise is that you open the dialogs with JavaScript only: http://www.telerik.com/help/aspnet-ajax/window-programming-opening.html. This will have the following benefits:
- you will not need to recreate server controls with each postback (as ASP requires for all dynamic controls)
- you will can avoid unnecessary postbacks
- without disposing the page (or, at least, the RadWIndowManager), the popups can keep their position and state even if other partial postbacks occur on the page.

RadWindowManager lets you create RadWindow instances dynamically with JavaScript, and then you can use the client-side API of the cotnrol to set needed properties (hide statusbar, set dimensions and position, etc.): http://www.telerik.com/help/aspnet-ajax/window-programming-radwindow-methods.html.

If you need to get information from the server (e.g., the URL) I advise you examine this article to see how you can register a script that will do the job, so you can avoid disposing the RadWIndowManager: http://www.telerik.com/help/aspnet-ajax/window-troubleshooting-opening-from-server.html. Thus, you can only pass an URL (and other parameters, if needed), to a function already created in the markup that will open the dialogs and set needed properties.

Alternatively, if you can declare the RadWindows in the RadWindowManager markup, you can try setting the PreserveClientState property of the manager to true. It will attempt to store the current bounds and size of the windows from the manager's collection to a cookie, but it is legacy functionality that may have issues. You can also consider using custom storage settings, as shown in this demo: http://demos.telerik.com/aspnet-ajax/persistence-framework/examples/custom-settings/defaultcs.aspx.

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 RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Window
Asked by
Mike
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Mike
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or