JS Error with RadWindow and custom print button

2 posts, 0 answers
  1. Edward Sudit
    Edward Sudit avatar
    30 posts
    Member since:
    Aug 2012

    Posted 23 Jun 2010 Link to this post

    I am using the code posted on this forum for adding a custom print button to the RadWindow title bar.  The code seems to work, but I get an error on the page that seems to be related to issuing the "insertBefore" command.  The code is provided in this post below. 

    The error message is:

        Message: Sys.ArgumentUndefinedException: Value cannot be undefined.
        Parameter name: handler
        Line: 2472
        Char: 16
        Code: 0

    <telerik:RadScriptBlock runat="server" ID="RadScriptBlock1">
        <script type="text/javascript">
            var radWnd;
            
            function <%=ClientID%>_OpenPrintWindow(url){
                radWnd = radopen(url, null);
                radWnd.set_title('Print Contract Form');
                radWnd.set_modal(true);
                radWnd.setSize(750,500);
                radWnd.center();
                radWnd.set_visibleStatusbar(false);
                radWnd.add_show(OnClientShow());
                radWnd.set_behaviors(Telerik.Web.UI.WindowBehaviors.Move +
                                     Telerik.Web.UI.WindowBehaviors.Close +
                                     Telerik.Web.UI.WindowBehaviors.Resize);
            }
            function OnClientShow()
            {
                var TitleBar = radWnd.GetTitlebar();
                var parent = TitleBar.parentNode;
                var oUL = parent.getElementsByTagName('UL')[0];
                if (!(oUL.firstChild.id == "customprintbuttonID")) // Check if the element is already added
                {
                    // If not - create and add the custom button
                    oUL.style.width = "192px";
                    var oLI = document.createElement("LI");
                    oLI.id = "customprintbuttonID"
                    var aPrintBtn = document.createElement("A");
                    oLI.appendChild(aPrintBtn);
                    aPrintBtn.className = "customprintbutton";
                    aPrintBtn.href = "javascript:void(0)";
                    aPrintBtn.title = "Print Content";
                    aPrintBtn.onmousedown = printWin;
                    oUL.insertBefore(oLI, oUL.firstChild);
                }
            }

            function printWin(e)
            {
                var content = radWnd.GetContentFrame().contentWindow;
                var printDocument = content.document;
                if (document.all)
                {
                    printDocument.execCommand("Print");
                }
                else
                {
                    content.print();
                }
                //Cancel event!
                if (!e) e = window.event;

                return $telerik.cancelRawEvent(e);
            }
         </script>        
    </telerik:RadScriptBlock>

  2. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 28 Jun 2010 Link to this post

    Hi Edward Sudit,

    I already answered your other forum thread on the same subject. For convenience I am pasting my reply below. If needed, please, let's continue the discussion in the other thread.


    The code that you posted is OK and is not raising such error on our side. I believe that the problem might be somewhere else on the page, but without having a better view over your case, I cannot tell for sure.

    Please open a support ticket and send me a small sample project where the problem could be reproduced - I will check it right away and do my best to help you.

    All the best,
    Georgi Tunev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top