locked
print textArea RRS feed

  • Question

  • User1230587063 posted

    hi all,

    I have textbox with multiline property and I want to enable user to print the content of it so what can I do to accomplish that.

                                                                                                                                      thanks in advance to everyone help me

                                                                                                                                         khalid

    Monday, March 17, 2008 8:21 AM

Answers

  • User-2115483147 posted

    hi all,

    I have textbox with multiline property and I want to enable user to print the content of it so what can I do to accomplish that.

                                                                                                                                      thanks in advance to everyone help me

                                                                                                                                         khalid

     

    Base on my understanding, you want to print part of the page, right?

    If so, please refer the following demo:  

    <%@ Page Language="C#" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <script runat="server">

    </script>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Print Demo</title>

        <script language="javascript" type="text/javascript">
    function doPrint() {
    bdhtml=window.document.body.innerHTML;
    sprnstr="<!--startprint-->";
    eprnstr="<!--endprint-->";

    prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);
    prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));
    window.document.body.innerHTML=prnhtml;
    window.print();
    }
        </script>

    </head>
    <body>
        <form id="form1" runat="server">
        <div id="WithoutPrint">
            This area will not print!
        </div>
        <div id="Print">
            <!--startprint-->
            This area will print!
            <!--endprint-->

        </div>
        <input id="btnPrint" type="button" value="Print" onclick="doPrint()" />
        </form>
    </body>
    </html>

    Let me know if I have misunderstood what you mean. Thanks.

    Hope it helps,

    Hong Gang
     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 19, 2008 11:41 PM

All replies

  • User537870505 posted
    One option is to use a pop up a new page with content to be printed (text box text) passed from the current page and let the user print it from the pop up page.
    Monday, March 17, 2008 8:39 AM
  • User-750661154 posted

     Take this i hope thing one might help  you.

    http://www.c-sharpcorner.com/UploadFile/mgold/NotepadDotNet07312005142055PM/NotepadDotNet.aspx?ArticleID=f0d1979f-e07d-4820-9f10-cbd52cdc2c8d

    Monday, March 17, 2008 8:51 AM
  • User-2115483147 posted

    hi all,

    I have textbox with multiline property and I want to enable user to print the content of it so what can I do to accomplish that.

                                                                                                                                      thanks in advance to everyone help me

                                                                                                                                         khalid

     

    Base on my understanding, you want to print part of the page, right?

    If so, please refer the following demo:  

    <%@ Page Language="C#" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <script runat="server">

    </script>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Print Demo</title>

        <script language="javascript" type="text/javascript">
    function doPrint() {
    bdhtml=window.document.body.innerHTML;
    sprnstr="<!--startprint-->";
    eprnstr="<!--endprint-->";

    prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);
    prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));
    window.document.body.innerHTML=prnhtml;
    window.print();
    }
        </script>

    </head>
    <body>
        <form id="form1" runat="server">
        <div id="WithoutPrint">
            This area will not print!
        </div>
        <div id="Print">
            <!--startprint-->
            This area will print!
            <!--endprint-->

        </div>
        <input id="btnPrint" type="button" value="Print" onclick="doPrint()" />
        </form>
    </body>
    </html>

    Let me know if I have misunderstood what you mean. Thanks.

    Hope it helps,

    Hong Gang
     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 19, 2008 11:41 PM
  • User1230587063 posted

    hi Hong Gang,

    thank you for help, but I didnt  want to print apart of page, the case that I have a textbox servercontrol with multiline , and I want to enable user to print the content of it.

    could you help me ?????

    thanks in advace

    khalid

    Wednesday, March 26, 2008 6:46 AM
  • User1230587063 posted

    hi Hong Gang,

    thanks in advance , your code solved my problem.

    khalid

     

    Wednesday, March 26, 2008 9:47 AM