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

Integrating the color picker

You can easily add a color picker to RichTextBox:

  1. Download the RichTextBox color picker ZIP file and open it up.
  2. Inside it is colorpicker.aspx, which is a C# page. To convert it to VB.NET open the page and swap the reference to Request["editor"] over to Request("editor"). i.e. change the square brackets to rounded brackets.
  3. Save the colorpicker.aspx file to your web application.
  4. Turn on the font foreground color picker button and/or the font background color picker button. Or even easier, to turn on everything on the toolbar including these two buttons, do this:
    myRichTextBox.QuickConfigure(Config.EnableAll)
  5. You may also need to check that the ColorPickerPath property correctly specifies the location of the colorpicker.aspx file. By default the editor will look for it in the root of the current web application.

When you click the link, the color picker will open and when you click a color, it will be applied to the document.

If you want to add a link to the color picker to your own client-side script, add a link or button to the page that opens the colorpicker.aspx page like this:
<button onclick=" showModalDialog('colorpicker.aspx?editor=XXXX_x5&command=forecolor', window,'dialogHeight=450px; dialogWidth=220px;status=no')" >Color picker</button>
Change the "XXXX" identifier to the one used by the RichTextBox on the page.

To add a color picker that sets the background color of the text (highlighting) change the "forecolor" text to "backcolor" in the JavaScript onclick code.

 




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