RadWindow closes immediately in non-IE7 browsers

4 posts, 0 answers
  1. John Mann
    John Mann avatar
    38 posts
    Member since:
    Nov 2008

    Posted 08 Jul 2009 Link to this post

    I have a page that pops up a RadWindow when a button is clicked. Works fine in IE7, but in IE8, Opera 9.64 and Chrome the window will flash up for just a moment and then close. The following code samples illustrate the problem.

    Parent window:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="TestApp.WebForm1" %> 
     
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml">  
    <head runat="server">  
      <title></title>  
      <script type="text/javascript">  
     
        function btnOpenRadWindow_onClick() {  
          var oManager = GetRadWindowManager();  
          oManager.open("WebForm2.aspx", "rwTest");  
        }  
     
        function ccbTest(sender, newText) {  
          // Do something here  
        }  
     
      </script> 
    </head> 
    <body> 
      <form id="form1" runat="server">  
      <telerik:RadScriptManager ID="RadScriptManager1" runat="server">  
      </telerik:RadScriptManager> 
      <div> 
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server" Skin="Vista" Behavior="Default" InitialBehavior="None" Left="" Top="" Style="display: none;" VisibleStatusbar="False">  
          <Windows> 
            <telerik:RadWindow ID="rwTest" runat="server" Behavior="Resize, Close, Move" Behaviors="Resize, Close, Move" InitialBehavior="None" NavigateUrl="WebForm2.aspx" ClientCallBackFunction="ccbTest" Modal="true" ReloadOnShow="True" Style="display: none;" VisibleStatusbar="False" ShowContentDuringLoad="False" AutoSize="true">  
            </telerik:RadWindow> 
          </Windows> 
        </telerik:RadWindowManager> 
        <button id="btnOpenRadWindow" onclick="btnOpenRadWindow_onClick()">Open Window</button> 
      </div> 
      </form> 
    </body> 
    </html> 
     

    Popup window:
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="TestApp.WebForm2" %> 
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml">  
    <head runat="server">  
      <title></title>  
      <script type="text/javascript">  
     
        function btnClose_onclick() {  
          var oWindow = GetRadWindow();  
          oWindow.argument = null;  
          oWindow.close(0);  
        }  
     
        function GetRadWindow() {  
          var oWindow = null;  
          if (window.radWindow)  
            oWindow = window.radWindow;  
          else if (window.frameElement.radWindow)  
            oWindow = window.frameElement.radWindow;  
          return oWindow;  
        }  
        
      </script> 
    </head> 
    <body> 
      <form id="form1" runat="server">  
      <div> 
        <button id="btnClose" onclick="return btnClose_onclick()" class="ButtonStandard">Cancel</button><br /> 
      </div> 
      </form> 
    </body> 
    </html> 
     

    I'm sure I'm doing something wrong since your samples work in these other browsers, but I haven't been able to figure it out yet. Can you shed some light on this please?

    John
  2. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 08 Jul 2009 Link to this post

    Hello John,

    You need to cancel the postback in order to avoid that.
    e.g.
    <button id="btnOpenRadWindow" onclick="btnOpenRadWindow_onClick(); return false;">Open Window</button>


    All the best,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. John Mann
    John Mann avatar
    38 posts
    Member since:
    Nov 2008

    Posted 09 Jul 2009 Link to this post

    Thank you, that fixed it. I figured it was something simple. I didn't realize that an HTML button caused a postback in these other browsers.

    John
  4. John Mann
    John Mann avatar
    38 posts
    Member since:
    Nov 2008

    Posted 10 Jul 2009 Link to this post

    After further investigation I learned that the default type for an html button is submit. IE7 appears to ignore this, but the other browsers I tried will honor that default and cause a postback. Another solution to the problem is to change the button's type. The following will work properly.

    <button id="btnOpenRadWindow" type="button" onclick="btnOpenRadWindow_onClick()">Open Window</button>

    John
Back to Top