Script Errors when using FileExplorer in RadWindow with URL

4 posts, 1 answers
  1. James Daresta
    James Daresta avatar
    59 posts
    Member since:
    Sep 2009

    Posted 23 Aug 2011 Link to this post

    I am setting up a dialog for the RadFileExplorer explorer using the RadWindow with it pointing to another page. However, everytime I click a file that is excel or word to open I am getting several script errors. The errors are as follows:

    Line: 19802
    Error: Invalid calling object

    Line: 6
    Error: Unable to get value of the property 'toLowerCase': object is null or undefined

    The dialog to open or save the file still comes up. When I debug the error I see it is something within th script manager itself. I have tried different things such as not using a master page, not using the RadScriptManager, removing Ajax Manager, etc. I am going to try an explicit file handler next to see if that will handle it (i.e FileSystemHandler.ashx?path=" + item.get_url();  ). Here is test code that replicates the issue. No code behind was needed.

    WebForm1.aspx

    <%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="FileExplorerInRadWindowWithMaster.WebForm1" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
     
    <telerik:RadCodeBlock ID="RD1" runat="server">
    <script type="text/javascript">
        function btnSalesContract_FileLink_Click(sender, args) {
            var rwSalesContract_ContractFileExplorer = $find('<%=rwSalesContract_ContractFileExplorer.ClientID %>');
     
            rwSalesContract_ContractFileExplorer.setUrl('FileDialog2.aspx');
            rwSalesContract_ContractFileExplorer.show();
        }
     
    </script>
    </telerik:RadCodeBlock>
     
                <telerik:RadButton ID="btnSalesContract_FileLink" runat="server"
                        Text="View Contract Files"
                        OnClientClicked="btnSalesContract_FileLink_Click"
                        ToolTip="Click to view this contract's files in Documentum"
                        Icon-PrimaryIconCssClass="rbEdit"
                        UseSubmitBehavior="false"
                        autopostback="false" />
     
     
    <telerik:RadWindow ID="rwSalesContract_ContractFileExplorer" runat="server" ClientIDMode="Static"
        Modal="true"
        AutoSize="true"
        Behaviors="Close"
        Style="z-index: 2000"
        ></telerik:RadWindow>
     
    </asp:Content>


    FileDialog.aspx
    <%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="FileDialog.aspx.cs" Inherits="FileExplorerInRadWindowWithMaster.FileDialog" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
        <telerik:RadFileExplorer ID="RadFileExplorer1" runat="server">
            <Configuration  ViewPaths="~/Files" />
        </telerik:RadFileExplorer>
    </asp:Content>

    Site1.Master

    <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="FileExplorerInRadWindowWithMaster.Site1" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <head id="Head1" runat="server">
        <title></title>
        <telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" />
    </head>
    <body>
        <form id="form2" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
                <%--Needed for JavaScript IntelliSense in VS2010--%>
                <%--For VS2008 replace RadScriptManager with ScriptManager--%>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
            </Scripts>
        </telerik:RadScriptManager>
        <script type="text/javascript">
            //Put your JavaScript code here.
        </script>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        </telerik:RadAjaxManager>
      
        <telerik:RadSkinManager ID="RadSkinManager1" Runat="server" Skin="Default">
        </telerik:RadSkinManager>
     
            <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
             
            </asp:ContentPlaceHolder>
     
        </form>
    </body>
    </html>





     
  2. Answer
    Marin Bratanov
    Admin
    Marin Bratanov avatar
    3595 posts

    Posted 25 Aug 2011 Link to this post

    Hi James,

      This seems to be an IE issue with iframes when the window.location property is changed. This is what the RadFileExplorer does which shows you the dialog box with open/save for the documents. You can reproduce the basic error quite easily with the following markup:
    in the Default.aspx:
    <iframe src="Default2.aspx" style="width: 800px; height: 600px;"></iframe>
    and in the Default2.aspx:
    <asp:Button ID="Button1" Text="change location" OnClientClick="changeLocation(); return false;" runat="server" />
    with the following script:
    function changeLocation()
    {
        window.location = "./Files/myFile.docx";
    }
    which, of course, assumes that the file is present.

      That being said I believe there is a workaround for this browser behavior. You can check whether the file is a doc, docx, etc and if so - cancel the default action and change the location of the topmost frame:
    function OnClientFileOpen(sender, args)
    {
        var path = args.get_path();
        if (path.indexOf(".docx") != -1)
        {
            args.set_cancel(true);
            window.top.location = args.get_path();
        }
    }
    The issue here stems from the possible differences in the clients' browser configurations - some may wish to display more files in the save/open dialog box than others and may experience this issue. For this, however, there is no workaround.

    As a reference I am attaching my test page and a video with the expected behavior: http://screencast.com/t/KNj8DN5cy.

    I also strongly advise that you remove the ClientIDMode property, since our controls do not support its Static mode, as many of them are actually containers.


    Greetings,
    Marin
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. James Daresta
    James Daresta avatar
    59 posts
    Member since:
    Sep 2009

    Posted 26 Aug 2011 Link to this post

    Thanks I ended up just doing the window.open in the client side passing the url to it. Works well for what I need.

    On the ClientIDMode is this something you are going to change in the future? This could cause issues for me as I take my javascript and put it into external javascript files for use with jQuery.
  5. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3595 posts

    Posted 30 Aug 2011 Link to this post

    Hi James,

    I am glad to hear that you have successfully worked out a solution.

    As for the ClientIDMode property - we do not plan on changing this behavior and we should not change it, as this is the way the framework is designed - container controls should change the IDs of their children. This is true even for simpler controls (like the standard ASP ones) and even more so for complex structures such as the RadControls. Some of our controls may work with a ClientIDMode set to Static, but this would be rather an exception, since many of our controls are containers and need this ID change. A prime example for this is the RadWindow. Another one is RadDock, for example.

    As for working with the ClientIDs in external files - I believe the following article a quick google search provided may be of help: http://jagregory.com/writings/how-to-use-clientids-in-javascript-without-the-ugliness/.


    Best wishes,
    Marin
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Back to Top