You can easily add a color picker to RichTextBox:
- Download the RichTextBox color picker ZIP file and open it up.
- 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.
- Save the colorpicker.aspx file to your web application.
- 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)
- 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.