Click here to Skip to main content
15,894,177 members
Articles / Web Development / XHTML

Integrating FCKeditor in ASP.NET

Rate me:
Please Sign up or sign in to vote.
4.43/5 (15 votes)
20 Jul 2008CPOL2 min read 270.1K   10.1K   64  
Integrating FCKeditor in ASP.NET
<%@ Page Title="FCK Editor MVC Demo" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="Fck.aspx.cs" Inherits="FCKEditorMvcDemo.Views.Home.Fck" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
    
    <script type="text/javascript" src="../../Content/Javascript/fckeditor/fckeditor.js"></script>
    <script type="text/javascript" src="../../Content/Javascript/fckeditorapi.js"></script>
    
    <script type="text/javascript">
    window.onload = function()
    {
        var oFCKeditor = new FCKeditor( 'content' ) ;
        oFCKeditor.BasePath = "/Content/Javascript/fckeditor/" ;
        oFCKeditor.Height = 300;
        oFCKeditor.ReplaceTextarea() ;
    }
    
    function InsertContent()
    {
        var oEditor = FCKeditorAPI.GetInstance('content') ;
        var sample = document.getElementById("sample").value;
        oEditor.InsertHtml(sample);
    }
    
    function ShowContent()
    {
        var oEditor = FCKeditorAPI.GetInstance('content') ;
        alert(oEditor.GetHTML());
    }
    
    function ClearContent()
    {
        var oEditor = FCKeditorAPI.GetInstance('content');
        oEditor.SetHTML("");
    }
    </script>
    
    <div>
        <input id="sample" type="text" /> 
        <input id="cmdInsert" type="button" value="Insert Content" onclick="InsertContent()" />
        &nbsp;
        <input id="cmdClear" type="button" value="Clear Content" onclick="ClearContent()" />
        <br /> <br />
        <textarea id="content" cols="30" rows="10"></textarea>
        <br />
        <input id="cmdShow" type="button" value="Show Content" onclick="ShowContent()" />
    </div>
</asp:Content>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Bangladesh Bangladesh
Software Engineer, Bangladesh.

Comments and Discussions