This is a migrated thread and some comments may be shown as answers.
Changing position of custom dialog in KB does not work
1 Answer 4 Views
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 05 Jan 2015, 09:05 PM
I have discovered that the solution offered for moving a custom dialog box from its' automatically centered position does not work.

Well, it does work, but when you successfully complete the dialog box (i.e. hitting a submit button), the RadWindow dialog reappears with no rhyme or reason and, furthermore, you can't close it or click any of the buttons.

...
<body>
    <form id="form1" runat="server">
    <table>
...
        <tr id="trFileName" runat="server">
            <td><asp:Label ID="lblFile" runat="server">File name:</asp:Label></td>
            <td><asp:FileUpload ID="txtFileName" runat="server" EnableViewState="true"></asp:FileUpload></td>
        </tr>
...
    </table>
 
    <asp:TextBox ID="txtOldFile" runat="server" style="display:none;" />
    <asp:Button ID="btnSubmit" runat="server" Text="Update" OnClientClick="insertLink();" />
  
    <script type="text/javascript">
        if (window.attachEvent) {
            window.attachEvent("onload", initDialog);
        }
        else if (window.addEventListener) {
            window.addEventListener("load", initDialog, false);
        }
 
        var workLink = null;
 
        function getRadWindow() {
            if (window.radWindow) {
                return window.radWindow;
            }
            if (window.frameElement && window.frameElement.radWindow) {
                return window.frameElement.radWindow;
            }
            return null;
        }
 
        function initDialog() {
            var clientParameters = getRadWindow().ClientParameters; //return the arguments supplied from the parent page
            getRadWindow().moveTo(50, 50); // <----- Commenting this line does not result in the window reappearing.
            //window.removeEventListener("load", initDialog, false); // <---- Tried this with no change in behavior.
            workLink = clientParameters;
        }
 
        function insertLink() //fires when the Insert Link button is clicked
        {
            //create an object and set some custom properties to it     
            var file = document.getElementById("<%=txtFileName.ClientID%>");
            var path = file.value;
            var ext = path.substring(path.lastIndexOf(".") + 1, path.length).toLowerCase();
 
            if (ext == null || ext == "") {
                workLink.href = document.getElementById("<%=txtOldFile.ClientID%>").value;
            } else {
                workLink.href = ext;
            }
 
            getRadWindow().close(workLink); //use the close function of the getRadWindow to close the dialog and pass the arguments from the dialog to the callback function on the main page.
        }
    </script>
  
    </form>
</body>
</html>

I'm guessing this KB was published quite a long time ago and has changed in future releases of Telerik AJAX.  Can you tell me if there's a way for me to fix this dilemma?  I have to move the dialog because I have a footer where the dialog hides under if the browser window is too small.

Thanks again!

1 Answer, 1 is accepted

Sort by
0
Ianko
Telerik team
answered on 07 Jan 2015, 09:26 AM
Hi Patrick,

I am unable to define how the moveTo method even affects the window's content to unresponsiveness.

Running the provided code I see that a JS error is being thrown in this piece of code:
if (ext == null || ext == "") {
    workLink.href = document.getElementById("<%=txtOldFile.ClientID%>").value;
} else {
    workLink.href = ext;
}

Here, the workLink is null and therefore there is no href attribute, afterwards the close() method of the window is never called. Subsequently a post back is performed and the RadWindow is shown as expected, because it has never been instructed to close itself.

Removing the code causing the JS error performs as expected: a JS error is not thrown, close method is called and a post back is not performed.
function insertLink() { //fires when the Insert Link button is clicked
 
    //create an object and set some custom properties to it    
 
    var file = document.getElementById("<%=txtFileName.ClientID%>");
    var path = file.value;
    var ext = path.substring(path.lastIndexOf(".") + 1, path.length).toLowerCase();
                 
    //if (ext == null || ext == "") {
    //  workLink.href = document.getElementById("<%=txtOldFile.ClientID%>").value;
    //} else {
    //  workLink.href = ext;
    //}
 
    getRadWindow().close(workLink); //use the close function of the getRadWindow to close the dialog and pass the arguments from the dialog to the callback function on the main page.
}

If there are still troubles with the matter, it would be better if you could prepare a working sample project, with which to reproduce this on my end.

Regards,
Ianko
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Asked by
Patrick
Top achievements
Rank 1
Answers by
Ianko
Telerik team
Share this question
or