Try Now
More in this section

Forums / Developing with Sitefinity / Custom Control for printing

Custom Control for printing

2 posts, 0 answered
  1. Luc Baeten
    Luc Baeten avatar
    169 posts
    23 Sep 2005
    10 Sep 2010
    Link to this post

    Based on the info I found in the artice http://www.telerik.com/support/kb/aspnet-ajax/window/adding-a-custom-button-to-radwindow-titlebar.aspx   I defined a custom control that should do the same.

    Below a simple implementation of the control I want to develop.

    ascx template print.ascx
    <%@ Control Language="C#" AutoEventWireup="true" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <script type="text/javascript">
        function OnClientShow(radWindow) {
            var TitleBar = radWindow.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 A = document.createElement("A");
                A.className = "customprintbutton";
                A.href = "javascript:void(0)";
                A.title = "Print Content";
                A.onmousedown = printWin;
                oUL.insertBefore(oLI, oUL.firstChild);
        function printWin(e) {
            var oManager = GetRadWindowManager();
            var oWnd = oManager.GetWindowByName("RadWindow1");
            var content = oWnd.GetContentFrame().contentWindow;
            var printDocument = content.document;
            if (document.all) {
            else {
            //Cancel event!
            if (!e) e = window.event;
            return $telerik.cancelRawEvent(e);
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
            <telerik:RadWindow ID="RadWindow1" runat="server" VisibleOnPageLoad="true" OnClientShow="OnClientShow"

    code behind print.cs
    using System;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Web.UI;
    namespace GBdealer.WebControls.WebClasses
        class Print : Telerik.Cms.Web.UI.SimpleControl
            /// <summary>
            /// Define Template for custom control
            /// </summary>
            public override string LayoutTemplateName
                    return layoutTemplateName;
            [WebSysTemplate(layoutTemplateName, "This is a description", "~/Templates/Print.ascx", true, "2010-04-15")]
            public override string LayoutTemplatePath
                    return base.LayoutTemplatePath;
                    base.LayoutTemplatePath = value;
            public override Type LocalizationAssemblyInfo
                    return base.LocalizationAssemblyInfo;
                    base.LocalizationAssemblyInfo = value;
            protected const string layoutTemplateName = "GBdealer.WebControls.Templates.Print.ascx";

    When I press the print button in the title bar of the window I get an Access denied error on the line : var printDocument = content.document;

    Have you any idea how to solve this problem?
    Hope you can help

    Kind regards
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    01 Feb 2016
    14 Sep 2010
    Link to this post
    Hello Luc Baeten,

    Can you try with some other page than Google.com? I am having no problems with this control when opening pages from my website. The problem is that you are trying to get the current document from another application.

    Kind regards,
    Radoslav Georgiev
    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
2 posts, 0 answered