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

RadWindow not closing via button

5 Answers 242 Views
Window
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 07 Mar 2011, 10:50 AM

Hi

I am following the following example to display an aspx page in popup radwindow.

http://demos.telerik.com/aspnet-ajax/window/examples/dialogreturnvalue/defaultcs.aspx

My code to display radwindow is given below at the end and is the equivalent of Dialog1.aspx in the above example. The code works fine and the content of the below aspx page opens fine in radwindow. Problem is when I click on the ‘I Accept’ button to close the radwindow and return the values to calling page (not included here) the radwindow closes but then reappears immediately. In other words the radwindow cannot be closed permanently using the ‘I Accept’ button. What is the problem and how can I make it work like the example in above link where pressing Submit button in dialog1.aspx closes the radwindow and returns values to calling form?

Many Thanks

Regards

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
  
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ViewDocument.aspx.cs" Inherits="SitefinityWebApp.Widgets.TestWidgets.ViewDocument" %>
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
    <title></title>
</head>
<body style="margin: 0px" onload="AdjustRadWidow();">
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <telerik:RadFormDecorator ID="RadFormDecorator1" DecoratedControls="All" runat="server"
        Skin="Sunset" />
    <script type="text/javascript">
        function GetRadWindow() {
            var oWindow = null;
            if (window.radWindow) oWindow = window.radWindow;
            else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
            return oWindow;
        }
  
        function openWin2() {
            var parentPage = GetRadWindow().BrowserWindow;
            var parentRadWindowManager = parentPage.GetRadWindowManager();
            var oWnd2 = parentRadWindowManager.open("Dialog2.aspx", "RadWindow2");
            window.setTimeout(function () {
                oWnd2.setActive(true);
            }, 0);
        }
  
        function populateCityName(arg) {
            var cityName = document.getElementById("cityName");
            cityName.value = arg;
        }
  
        function AdjustRadWidow() {
            var oWindow = GetRadWindow();
            setTimeout(function () { oWindow.autoSize(true); if ($telerik.isChrome || $telerik.isSafari) ChromeSafariFix(oWindow); }, 500);
        }
  
        //fix for Chrome/Safari due to absolute positioned popup not counted as part of the content page layout
        function ChromeSafariFix(oWindow) {
            var iframe = oWindow.get_contentFrame();
            var body = iframe.contentWindow.document.body;
  
            setTimeout(function () {
                var height = body.scrollHeight;
                var width = body.scrollWidth;
  
                var iframeBounds = $telerik.getBounds(iframe);
                var heightDelta = height - iframeBounds.height;
                var widthDelta = width - iframeBounds.width;
  
                if (heightDelta > 0) oWindow.set_height(oWindow.get_height() + heightDelta);
                if (widthDelta > 0) oWindow.set_width(oWindow.get_width() + widthDelta);
                oWindow.center();
  
            }, 310);
        }
  
        function returnToParent() {
            //create the argument that will be returned to the parent page
            var oArg = new Object();
  
  
            oArg.cityName = "London";
  
            oArg.selDate = toLocaleString();
  
            //get a reference to the current RadWindow
            var oWnd = GetRadWindow();
  
            //Close the RadWindow and send the argument to the parent page
            if (oArg.selDate && oArg.cityName) {
                oWnd.close(oArg);
            }
            else {
                alert("Please fill both fields");
            }
        }
    </script>
    <div>
        <asp:Panel ID="Panel1" runat="server" Height="100%" Width="100%">
            <table style="width: 100%; height: 100%;">
                <tr>
                    <td colspan="3">
                           
                        <asp:Literal ID="Literal1" runat="server"></asp:Literal>
                    </td>
                </tr>
                <tr>
                    <td colspan="3">
                             
                    </td>
                </tr>
                <tr>
                    <td align="center" width="40%">
                           
                    </td>
                    <td align="center" width="10%" style="width: 20%">
                        <button title="I Accept" id="close" onclick="returnToParent(); return true;">
                            I Accept</button>
                    </td>
                </tr>
  
            </table>
        </asp:Panel>
    </div>
    </form>
</body>
</html>

5 Answers, 1 is accepted

Sort by
0
John
Top achievements
Rank 1
answered on 07 Mar 2011, 01:00 PM

The second issue is that the radwindow that comes up has its left border chopped off (image radwindow1.jpg) and in general does not have as elegant a border as in the sample (radwindow2.jpg.)

Thanks

Regards

0
Georgi Tunev
Telerik team
answered on 10 Mar 2011, 04:35 PM
Hi John,

The code that you posted looks OK so at this point I assume that the problem might be in the parent page. Do you make a postback in the parent after you close the RadWindow? If so, try setting EnableViewState to false and see if it helps. If it doesn't, it will be best to open a support ticket and to send us a sample project that isolates the problem so we can investigate further.

Kind regards,
Georgi Tunev
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Satya
Top achievements
Rank 1
answered on 08 Mar 2012, 10:25 PM
Is this Issue has been resolved? I am only getting this issue when I host my user control with in another user control otherwise it works perfectly fine.

Thanks,
Satya
0
Marin Bratanov
Telerik team
answered on 09 Mar 2012, 04:43 PM
Hello Satya,

We have not received further information regarding this thread and I cannot confirm how/if the original poster resolved the problem. It is possible that my colleague's suggestion to remove the viewstate helped. Please try it as well, especially if you are opening the RadWindow from the server.

You should also take a look at your JS code - are calling somewhere methods like center(), maximize(), moveTo() on this RadWindow after it is closed? This should not be done as they also modify its visibility.


Kind regards,
Marin
the Telerik team
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 their blog feed now.
0
Satya
Top achievements
Rank 1
answered on 09 Mar 2012, 05:43 PM
Hi Marin,
Thank you for your solution. I made changes as per above suggestion in link you have provided and removed the center() and it  started working.

Thanks,
Satya
Tags
Window
Asked by
John
Top achievements
Rank 1
Answers by
John
Top achievements
Rank 1
Georgi Tunev
Telerik team
Satya
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or