C# .NET - how to design html editor using asp.net+c#

Asked By chinna samy on 21-Oct-08 05:10 AM
how to design html editor using asp.net+c#

re - Web Star replied to chinna samy on 21-Oct-08 05:21 AM


The component itself contains many different HTML elements, so the server control class is derived from CompositeControl. In addition, the class must implement the IScriptControl methods:

public class HtmlEditor : CompositeControl, IScriptControl

In CompositeControl, child controls are added in the CreateChildControls method:

protected override void CreateChildControls()




To implement the IScriptControl interface, two callback methods are required. The first, GetScriptReferences, tells ScriptManager what related script file(s) to load and from where. For this server control, we have chosen to embed the HtmlEditor.js file in our assembly resources. We tell ScriptManager the full resource path and assembly name so that it can load it from there, simplifying deployment:

protected virtual IEnumerable<ScriptReference>
    ScriptReference htmlEditorReference =
        new ScriptReference(


    return new ScriptReference[] { htmlEditorReference, ... };

The second callback method, GetScriptDescriptors, "maps" properties in the client control(s) to properties in the server control. ScriptManager uses this information to set the appropriate values in the client control as part of its client-side creation:

protected virtual IEnumerable<ScriptDescriptor>

    ScriptControlDescriptor descriptor =
        new ScriptControlDescriptor("Winthusiasm.HtmlEditor",


    return new ScriptDescriptor[] { descriptor };

Although we have now implemented the IScriptControl methods, there are two remaining modifications to make so that the IScriptControl callbacks get called. First, OnPreRender must be modified to call RegisterScriptControl, as follows:

protected override void OnPreRender(EventArgs e)

    if (!this.DesignMode)
        // Test for ScriptManager and register if it exists.

        sm = ScriptManager.GetCurrent(Page);

        if (sm == null)
            throw new HttpException(
            "A ScriptManager control must exist on the page.");




Then Render must be modified to call RegisterScriptDescriptors:

protected override void Render(HtmlTextWriter writer)
    if (!this.DesignMode)


HTML editor - mv ark replied to chinna samy on 21-Oct-08 05:31 AM

Building your own HTML editor can be laborious & time-consuming. In case you want it to work on popular browsers, you would have to test on a variety of browsers & their versions. So I suggest that rather than building your own, take a look at these free HTML text editor controls that have good cross browser support:
Free Text Box - http://freetextbox.com/features/
FCKeditor - http://www.fckeditor.net/
TinyMCE - http://sourceforge.net/projects/tinymce/

FCKEditor & TinyMCE are open source.

They are extensively tested & as the last two are open source, you can tweak the code to customize.

read this link - C_A P replied to chinna samy on 21-Oct-08 05:44 AM

read this link - C_A P replied to chinna samy on 21-Oct-08 05:45 AM