ASP.NET – CKEditor For ASP.NET 使用方法
web.config |
<configuration> <system.web> … … <pages> <controls> <add tagPrefix="CKEditor" assembly="CKEditor.NET" namespace="CKEditor.NET" /> </controls> </pages> </system.web> </configuration> |
WebForm2.aspx |
<link href="sample.css" rel="stylesheet" type="text/css" /> … … <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <div> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <CKEditor:CKEditorControl Width="700" ID="CKEditor1" runat="server" StartupOutlineBlocks="True" AutoPostBack="true" /> <asp:Literal ID="Literal1" runat="server" /> </ContentTemplate> </asp:UpdatePanel> </div> </form> |
WebForm2.aspx.cs |
using System; using CKEditor.NET; namespace WebApplication1 { public partial class WebForm2 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { CKEditor1.TextChanged +=new EventHandler(CKEditor1_TextChanged); CKEditor1.config.toolbar = new object[] { new object[] { "Source", "-", "Save", "NewPage", "Preview", "-", "Templates" }, new object[] { "Cut", "Copy", "Paste", "PasteText", "PasteFromWord", "-", "Print", "SpellChecker", "Scayt" }, new object[] { "Undo", "Redo", "-", "Find", "Replace", "-", "SelectAll", "RemoveFormat" }, new object[] { "Form", "Checkbox", "Radio", "TextField", "Textarea", "Select", "Button", "ImageButton", "HiddenField" }, "/", new object[] { "Bold", "Italic", "Underline", "Strike", "-", "Subscript", "Superscript" }, new object[] { "NumberedList", "BulletedList", "-", "Outdent", "Indent", "Blockquote", "CreateDiv" }, new object[] { "JustifyLeft", "JustifyCenter", "JustifyRight", "JustifyBlock" }, new object[] { "BidiLtr", "BidiRtl" }, new object[] { "Link", "Unlink", "Anchor" }, new object[] { "Image", "Flash", "Table", "HorizontalRule", "Smiley", "SpecialChar", "PageBreak", "Iframe" }, "/", new object[] { "Styles", "Format", "Font", "FontSize" }, new object[] { "TextColor", "BGColor" }, new object[] { "Maximize", "ShowBlocks", "-", "About" } }; } void CKEditor1_TextChanged(object sender, EventArgs e) { Literal1.Text = CKEditor1.Text; } } } |