Rich Text Editor Control

I have developed an ASP.NET Rich Text Editor control, which works nicely (minus one key feature).  The issue is I am having trouble with, is getting the data from the RTE to the code behind page where it can be used, written to a file, etc.

Basically, I want to be able to use the RTE like I would an asp:textbox, as in placing the control on a page, and having access to it, programatically through code behind pages.

I see only one way to do this, is to have a hidden input field embedded with the control.  Once the form is submitted, the value of the RTE will be written to  the hidden field, which I can then access via a Request or HtmlControl.

The tricky part is that this has to be done before the form posts back, via a javacript.  I can do this manually by adding an "onsubmit" event to the form of the page, but I want this control to be self sufficient.

How can I programatically, attach an "onsubmit" call to a form of an aspx page?
Who is Participating?
Jens FiedererConnect With a Mentor Test Developer/ValidatorCommented:
For Internet Explorer, attachEvent will do the job.

var myElement=document.getElementById('hiddenElement');

myElement.form.attachEvent('onsubmit', YourHandlerFunction);

However, this is not portable to other browsers.

For a more portable solution, you can use the Page.RegisterOnSubmitStatement method on the server side while loading your control.
Can add it manually in the aspx page, ie:

<form id=frm onsubmit="filHiddenField()">

   document.getElementById('hidden1Content').text =  document.getElementById('yourEdiableDiv').innerHTML;
r u using the richtextbox provided to be used as a server control .. u will get the latest download from their site .. reference the dll in ur project .. then register it in ur aspx page
<%@ Register TagPrefix="RTB" Namespace="RichTextBoxControl" Assembly="RichTextBox"%>
then use this tag
<RTB:RICHTEXTBOX id="RichtextBox1" runat="server" Width="93%" BorderStyle="None" BorderWidth="2px"
                                          HtmlOptionIsEnabled="False" ToolbarAutoHideIsEnabled="False" ToolbarLayout="fontmenu,fontsizemenu,fontforecolormenu,fontbackcolormenu,bold,italic,underline:superscript,subscript,strikethrough,separator,leftjustify,centerjustify,rightjustify,separator,numberedlist,bullets,outdent,indent,separator,cut,copy,paste,separator,undo,redo,separator,print,insertdate,inserttime"

and in the code beind it is accessble as a normal server control ...
like to access the text u can use RichtextBox1.Text

I have used this and it works fine ..
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

mmarksburyAuthor Commented:
Rejojhny, that is the goal with my control, and I am almost there.  For reference however, what is the site you are talking about?
have a look here

i think u should find lots of these controls if u search the net ..
mmarksburyAuthor Commented:
Thanks.  I'm not looking to PURCHASE an RTE control.  

I will try the  "Page.RegisterOnSubmitStatement" and any other suggestions this evening, and award the winner at that time.

You could try   which is pretty awesome. (and FREE)
i thought u already had the richtextbox control ..
mmarksburyAuthor Commented:
Thanks, that's exactly what I was asking for, a way to attach an onsubit method to my form programatically from the Server Side.  Thanks
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.