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

RadWindow Appears and disappears

3 Answers 231 Views
Window
This is a migrated thread and some comments may be shown as answers.
Dobre
Top achievements
Rank 1
Dobre asked on 27 Jun 2013, 12:29 PM
Hello,
I have the following situation:

Site.Master:
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" EnablePartialRendering="true">
             <Scripts>
            <%--Framework scripts--%>
           <asp:ScriptReference Name="MsAjaxBundle" />
            ................................................................
                 </Scripts>
        </asp:ScriptManager>
 <telerik:RadWindowManager ID="RadWindowManagerL" runat="server" AnimationDuration="3000" EnableViewState="false"> </telerik:RadWindowManager>

 <asp:UpdatePanel ID="UP" runat="server">
           <ContentTemplate>
                 <asp:ContentPlaceHolder runat="server" ID="MainContent" />
           </ContentTemplate>
  </asp:UpdatePanel>


somename.aspx:
..............................
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server"> <%-- this is the content that is placed in the UpdatePanel -->
.........................
<asp:Button ID="btneditc" runat="server" Width="40px" Text="Edit" Font-Size="Small" Height="28px" BorderColor="#043C77" ForeColor="#043C77"  />
........................................
<script type="text/javascript">
   function show(nameRadWindow) {
                    var name= String(nameRadWindow);
                    var manager = GetRadWindowManager();
                    var window = manager.getWindowByName(name);
                    window.show();
    window.focus();
                }
            </script>
</asp:Content>

somename.aspx.vb:
Public Class somename
    Inherits System.Web.UI.Page
    Dim IsFirstTime As Boolean = True
   
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
               If (Not IsPostBack) And IsFirstTime = True Then                    
createWin()
IsFirstTime = False
End if

Public Sub createWin() 
 Dim numFer As Integer = DirectCast(Me.Master.FindControl("RadWindowManagerL"), RadWindowManager).Windows.Count()
        Try
            If numFer <> 0 Then
                DirectCast(Me.Master.FindControl("RadWindowManagerL"), RadWindowManager).Windows.Clear()
            End If
        Catch ex As Exception

        End Try
        Dim arrayWindow(3, 4) As String

        arrayWindow(0, 0) = "radWindowOne" 
        arrayWindow(1, 0) = "windowOne.aspx" 
        arrayWindow(2, 0) = "Window One Title" '
        arrayWindow(3, 0) = "divname
"     

        arrayWindow(0, 1) = "radWIndowTwo" 
        arrayWindow(1, 1) = "windowTwo.aspx" 
        arrayWindow(2, 1) = "Window two Title" 
        arrayWindow(3, 1) = "divname"
"     

        arrayWindow(0, 2) = "radWindowThree" 
        arrayWindow(1, 2) = "windowThree.aspx" 
        arrayWindow(2, 2) = "Window Three Title" 
        arrayWindow(3, 2) = "divname"
"     

        arrayWindow(0, 3) = "radWindowFour"
        arrayWindow(1, 3) = "windowFour.aspx" 
        arrayWindow(2, 3) = "Window Four Title" 
        arrayWindow(3, 3) = "divname"
"     

        arrayWindow(0, 4) = "radWindowFive" 
        arrayWindow(1, 4) = "windowFive.aspx" 
        arrayWindow(2, 4) = "Window Five Title"  
        arrayWindow(3, 4) = "divname"    


        For i As Integer = 0 To 4
            Dim window As New Telerik.Web.UI.RadWindow()
            With window
                .ID = arrayWindow(0, i)
                .NavigateUrl = arrayWindow(1, i)
                .Title = arrayWindow(2, i)
                .RestrictionZoneID = arrayWindow(3, i)

                .EnableViewState = False
                .VisibleOnPageLoad = False
                .ReloadOnShow = False
                .ShowContentDuringLoad = False
                .DestroyOnClose = False
                .Behaviors = WindowBehaviors.Move Or WindowBehaviors.Close Or WindowBehaviors.Resize
                .VisibleStatusbar = False
                .Modal = True
                .Skin = "Metro"
                .EnableEmbeddedSkins = False
                .Height = 440
                .Width = 750
            End With

            DirectCast(Me.Master.FindControl("RadWindowManagerlocatii"), RadWindowManager).Windows.Add(window)
' All the windows are succesfully added
        Next
End Sub

 Protected Sub btneditc_Click(sender As Object, e As EventArgs) Handles btneditc.Click
        'ScriptManager.RegisterStartupScript(Me, Me.GetType(), "openWnd", "show('radWindowOne'); return false;", True)
        'ScriptManager.RegisterStartupScript(Me, Me.GetType(), "openWnd", "show('radWindowFive'); return false;", True)
' If i try to open Window one, all things are ok the window is opened and doesn`t disappear
' if I try to open Window five , the window appears for 1 sec and disappears


    End Sub

The code for WindowOne.aspx/vb and WindowFive.aspx/vb is the same
I tried to call the JS function show() from aspx too : OnClientClick="show('nameofthewindow'); return false;" but doesn t work :( and I can't use RadScriptManager and AJAX because in somename.aspx a have a lot of UI oject (radgrids, etc...)




3 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 28 Jun 2013, 10:37 AM
Hello Dobre,

A RadWindow would show and immediately hide if a postback disposed it, and since the provided declaration does not add differences between the first and the fifth popup the difference must be somewhere else on the page.

What I can also suggest is trying to add these RadWindows declaratively in the manager instead of dynamically in the code-behind to see if this will make a difference.

I would also strongly advise against using the "window" name for a variable name in your scripts, as it is s reserved variable for the browser window object. To open a popup you can simply call radopen() and set properties for the control afterwards if needed. You can set common settings for the manager (restriction zone, reloadOnShow, etc.) to have all its children inherit them automatically.
http://www.telerik.com/help/aspnet-ajax/window-programming-opening.html
http://www.telerik.com/help/aspnet-ajax/window-programming-radwindow-methods.html

Since you are working with scripts called from the server I also advise you examine the following resources on using the Sys.Application.Load event to ensure they are not executed too early:
http://www.telerik.com/community/forums/aspnet-ajax/window/opening-radwindow-from-the-server.aspx
http://www.telerik.com/help/aspnet-ajax/radwindow-troubleshooting-javascript-from-server-side.html


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.
0
Dobre
Top achievements
Rank 1
answered on 02 Jul 2013, 10:14 AM
So I tried this:

Site.Master:
 <telerik:RadWindowManager ID="RadWindowManagerlocatii" runat="server" AnimationDuration="3000" EnableViewState="false" VisibleOnPageLoad ="False" ReloadOnShow="true" ShowContentDuringLoad="false" DestroyOnClose="false" Behaviors="Close" VisibleStatusbar="false" Modal="true" Skin="Metro" EnableEmbeddedSkins="false" Height ="440" Width="750">   
            <Windows>
                <telerik:RadWindow ID="radWindowAutoConf" runat="server" Title="Auto Configurare"></telerik:RadWindow>
                <telerik:RadWindow ID="radWindowEdit" runat="server" Title="Editare Contoare"></telerik:RadWindow>
            </Windows>
        </telerik:RadWindowManager>

somename.aspx:
 <asp:Button ID="btnsave1" runat="server" OnClick="Button1_Click" />
      <asp:Button ID="btnsave2" runat="server" OnClick="Button2_Click" />


<script type="text/js">
                function showautoconfig() {
                    var manager = GetRadWindowManager();
                    manager.open("autoconf.aspx", "radWindowEdit");
                }
function showedit() {
                    var manager = GetRadWindowManager();
                    manager.open("edit.aspx", "radWindowAutoConf");
                }
</script>

somnename.aspx.vb :
Protected Sub Button1_Click(sender As Object, e As EventArgs)
      ScriptManager.RegisterStartupScript(Me, Me.GetType(), "openWndAutoconfig", "showedit(); return false;", True  ) 
End Sub
Protected Sub Button2_Click(sender As Object, e As EventArgs)
      ScriptManager.RegisterStartupScript(Me, Me.GetType(), "openWndAutoconfig", "showautoconfig(); return false;", True  ) 
End Sub

Site_windows.Master.vb:
<%@ Master Language="VB" AutoEventWireup="false" CodeBehind="Site_windows.Master.vb" Inherits="Energsys.Site_windows" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<link href="Content/contor.css" rel="stylesheet" />
<link href="Content/filtrelocatii.css" rel="stylesheet" />
<link href="Content/filtrelocmasura.css" rel="stylesheet" />
<link href="Content/filtregrup.css" rel="stylesheet" />
<link href="Content/addgrup.css" rel="stylesheet" />
<link href="Content/istoricpm.css" rel="stylesheet" />
<link href="Content/schimbareml.css" rel="stylesheet" />
<link href="Content/Site_windows.css" rel="stylesheet" />
<link href="Content/autoconfig.css" rel="stylesheet" />
<script src="Scripts/closePopUpWindows.js"></script>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="editcontor" runat="server">
        <asp:scriptmanager ID="ScriptManagereditcontor" runat="server"></asp:scriptmanager>
  
        <section class="content-wrapper main-content clear-fix">
            <asp:UpdatePanel ID="UP1" runat="server">
                <ContentTemplate>
                    <asp:ContentPlaceHolder runat="server" ID="MainContent" />
                </ContentTemplate>
            </asp:UpdatePanel>
        </section>

    </form>
</body>
</html>

autoconf.aspx: empty
edit.aspx: empty
edit.aspx.vb and autoconf.aspx.vb are empty


All the things are the same: when i press button 1 the window appears and it's ok, when i press button 2 it appears and the page is refreshed and disappears. I really don't understand why, the windows are the same.
0
Marin Bratanov
Telerik team
answered on 03 Jul 2013, 01:51 PM
Hi,

I tried this code and it is working fine with me. You can find attached my test pages and a short video as a reference. At this point I can advise that you compare your setup with mine to see what is the difference that causes the problem. A possible reason for the RadWindow to close can also be a call to window.close() or GetRadWindow().close() from the page inside. Such a script can be present if an external script file is referenced there.


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
Dobre
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Dobre
Top achievements
Rank 1
Share this question
or