This is a migrated thread and some comments may be shown as answers.

How to print the parent window from radWindow?

3 Answers 216 Views
Window
This is a migrated thread and some comments may be shown as answers.
Adam Cole
Top achievements
Rank 1
Adam Cole asked on 05 May 2009, 06:59 PM
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

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 06 May 2009, 04:53 AM
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.
0
Adam Cole
Top achievements
Rank 1
answered on 06 May 2009, 02:36 PM
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.
0
Fiko
Telerik team
answered on 06 May 2009, 03:41 PM
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.
Tags
Window
Asked by
Adam Cole
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Adam Cole
Top achievements
Rank 1
Fiko
Telerik team
Share this question
or