How to print the parent window from radWindow?

4 posts, 0 answers
  1. Adam Cole
    Adam Cole avatar
    31 posts
    Member since:
    Nov 2004

    Posted 05 May 2009 Link to this post

    Hi,
      Please let me know if it's possible to do this.

      Basically, I want to build a web form to collect some information from the user.  There is a submit button on the form and when the user click on the submit button, a radWindow will pop up.  Inside the radWindow, I have three buttons: "Print", "Save", and "Cancel".
     
      "Save" button will just save everything in the web form.
      "Cancel" button will close the radWindow and go back to the web form.
      "Print" button will print the content on web form.  I want to keep the radWindow open when user click on "Print" button.

      I figured out how to do "Save" and "Cancel", but I couldn't figure how to print the content on the web form (parent page) and keep the radWindow open.

      I tried some simple javascript, like calling window.print.print() from the radWindow, but it didn't work.

      Can you show me a way to do the "Print" button?

    Thanks
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 05 May 2009 Link to this post

    Hi Adam Cole,

    You can call a parent window client side function from radwindow and then use the window.print() method to print the page. Try the following approach and see whether it working fine.

    Parent Page:
    [aspx]
     
    <telerik:radwindowmanager id="RadWindowManager1" runat="server"
    <Windows> 
    <telerik:RadWindow runat="server" NavigateUrl="Window.aspx" OpenerElementID="Button1"></telerik:RadWindow> 
    </Windows> 
    </telerik:radwindowmanager> 
    <asp:Button ID="Button1" runat="server" Text="Open Window" /> 

    [javascript]
     
    <script type="text/javascript"
    function printpage() 
        window.print();  // For printing the page 
    </script> 

    Page opened in RadWindow:

    [aspx]
     
    <input id="Button2" type="button" value="Print" onclick="print();" /> 

    [javascript]
     
    <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 print() 
        var oBrowserWnd = GetRadWindow().BrowserWindow; 
        oBrowserWnd.printpage();  // Calls the parent window function 
    </script> 

    Thanks,
    Shinu.
  3. Adam Cole
    Adam Cole avatar
    31 posts
    Member since:
    Nov 2004

    Posted 06 May 2009 Link to this post

    Hi Shinu,
      Thank you for the reply.

      I tried your code and it printed both parent and child windows (child on top of the parent).

      I checked the source code and found out the radWindow is not really a pop-up window, it's a <div> in the parent window.  Maybe that's why it printed both parent and child.

      Any other idea?

    Thanks.
  4. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 06 May 2009 Link to this post

    Hi Adam,

    I already answered your support ticket, but I believe that the provided solution will be of help for the other clients. That is why I have attached it to this thread.

    I hope this helps.

    Best wishes,
    Fiko
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top