[CLOSED] Print window content

  1. #1

    [CLOSED] Print window content

    Hello,

    I need to print the html contained within a window without printing the button that triggers the impression.

    I already researched some threads in the forum related, however i could not solve my problem with any of them.

    In this thread: http://forums.ext.net/showthread.php...indow-Contents I saw that a possible solution would be the following javascript code:

     
    <ext:Button runat="server" Text="Print" Icon="Printer">
          <Listeners>
                 <Click Handler="#{Window1}.getBody().print()" />
           </Listeners>
    </ext:Button>
    But this code give me the following javascript error: "Uncaught TypeError: Object [object Object] has no method 'print'"

    Anyway I need any solution that prints only the html contained in the window. In my example, the result would only be printed the word "Test".

    This is my full example code:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="CidadeDaConfeccao.Test" %>
    
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">    
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:Window ID="Window1" runat="server" Title="Window" Width="400" Height="400">
            <BottomBar>
                <ext:Toolbar ID="Toolbar1" runat="server">
                    <Items>
                        <ext:Button ID="Button1" runat="server" Text="Print" Icon="Printer">
                            <Listeners>
                                <Click Handler="#{Window1}.getBody().print()"/>
                            </Listeners>
                        </ext:Button>
                    </Items>
                </ext:Toolbar>
            </BottomBar>
            <Content>
                <asp:Panel ID="PainelBoleto" runat="server">
                Test
                </asp:Panel>
            </Content>
        </ext:Window>
        </form>
    </body>
    </html>
    Thanks.
    Last edited by Daniil; Mar 04, 2013 at 7:49 AM. Reason: [CLOSED]
  2. #2
    Hello!

    You can print only the whole page. This code
    #{Window1}.getBody().print()
    works only if you load content of the window in IFrame mode which is separate HTML page and using getBody() you can access window object of this frame

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">   
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:Window ID="Window1" runat="server" Title="Window" Width="400" Height="400">
            <AutoLoad Url="OtherWebForm.aspx" Mode="IFrame"></AutoLoad>
            <BottomBar>
                <ext:Toolbar ID="Toolbar1" runat="server">
                    <Items>
                        <ext:Button ID="Button1" runat="server" Text="Print" Icon="Printer">
                            <Listeners>
                                <Click Handler="#{Window1}.getBody().print()"/>
                            </Listeners>
                        </ext:Button>
                    </Items>
                </ext:Toolbar>
            </BottomBar>
        </ext:Window>
        </form>
    </body>
    </html>
  3. #3
    Ok Daulet, I get it.

    However in my case, I don't want to use the IFrame.

    Is there any way to print the contents of the component "asp:Panel" from the window without using IFrames?

    And using an "ext:Label" inside the window is it possible?

    Thank you.
  4. #4
    No, browser allows to print whole page (or iframe) only.
    If you need to print part only then need to create temp iframe, place required info/html to that iframe and call print method for that iframe
  5. #5

    ext 2.0 print window

    Hello!
    You example for Ext 1.0
    i writing in 2.4 version - load html file from disk :
    <ext:Window ID="wndShowDoc" runat="server" Title="" Icon="UserHome" BodyPadding="0"  AutoScroll="true"  TagString="iframe"
               Width="900" Height="600"  Modal="true" Resizable="true" Closable="true" Hidden="true" Layout="Fit" CloseAction="Hide">
                <Items>
              <ext:Panel runat="server" ID="ctl39" >
                        <Buttons>
                            <ext:Button ID="btPrints" runat="server" Text="Print" Icon="Printer">
                              <Listeners>
                                     <Click Handler="this.up('window').getBody().print;" />
                               </Listeners>
                            </ext:Button>
                           <ext:Button runat="server" Icon="Decline" Text="Close" ID="ctl195" >
                                        <Listeners>
                                            <Click Handler="this.up('window').hide();" />
                                         </Listeners>
                            </ext:Button>
                  
                        </Buttons>
                         <Loader ID="Loader1" 
                                        runat="server" 
                                        AutoLoad="false"
                                        Url="~/Handler/Handler1.ashx" 
                                      
                                        Mode="Frame">
                                    <Params>
                                        <ext:Parameter Name="ext" Value="html" Mode="Value" />
                                        <ext:Parameter Name="link" Value="c:\1\1.html" Mode="Value" />
                                  </Params> 
                              <LoadMask ShowMask="true" />
                        </Loader>
                 </ext:Panel>
                </Items>
             </ext:Window>
    but after click on button Print - nothing..
    may be problem - Panel?
    Please Help.. thanks
    Last edited by asics167; Jan 17, 2014 at 5:27 PM.
  6. #6

    answer

    i found - only change window on panel - and its work :
    <ext:Button ID="btPrints" runat="server" Text="Печать" Icon="Printer">
                              <Listeners>
                                     <Click Handler="this.up('panel').getBody().print();" />
                               </Listeners>

Similar Threads

  1. [CLOSED] How I print ext:Window content?
    By supera in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 29, 2012, 4:00 PM
  2. Replies: 6
    Last Post: Feb 18, 2011, 2:12 PM
  3. Replies: 1
    Last Post: Mar 25, 2010, 5:59 PM
  4. Print content inside a panel
    By Nagaraj K Hebbar in forum 1.x Help
    Replies: 0
    Last Post: May 19, 2009, 2:14 AM

Tags for this Thread

Posting Permissions