Knowledge Base > RichTextBox > Features Knowledge Base Home | Login
Search the Knowledge Base
 
Start Search in the Following Category

Printing Selective Content

The RichTextBox print toolbar button only prints the content of the RichTextBox editor with the following javascript -

 

RTB_Print(RichTextBox1_x5,RTB_HtmlMode_RichTextBox1());

 

function RTB_Print(editor,htmlmode)

{

    editor.document.execCommand('print','',null);

}

 

If you wish to print selective content from the RichTextBox and other Text elements when the Print Toolbar button is clicked you’ll need to override the existing print button (example code below) and then add some javascript that opens a new IFrame and writes the content that you want to print from your own Html Text elements and the RichTextBox and then prints this.

 

See the thread at http://www.experts-exchange.com/Web/Q_20862959.html for an example of creating the new frame and printing.

 

Code to override existing Print button onclick function call -

 

protected RichTextBoxControl.ToolbarButton toolButton;

 

private void Page_Load(object sender, System.EventArgs e)

 {

     toolButton = new RichTextBoxControl.ToolbarButton("Print", true);

     toolButton.ClientOnClickFunction = "myButtonHandler";

     this.RichTextBox1.CreateToolbarButton(toolButton);

 }

 

Then javascript function in page -

<script language=javascript type=text/javascript>s

  function myButtonHandler(editor, isHtmlMode)

  {

      alert('print');

      //add your own print logic here

  }

</script>

 




Did this page answer your question? If not, try the Forums or contact us.

Copyright Richer Components 2005. All rights reserved. No part of this article may be reproduced or transmitted in any form, by any means (electronic, photocopying, recording or otherwise) without the prior written permission of Richer Components. All brand names and product names used in this article are trade names, service marks, trademarks, or registered trademarks of their respective owners.


Knowledge Base Software - myKB.com