简体   繁体   English

将CKEditor集成到ASP.Net Webforms应用程序中

[英]Integrating CKEditor in an ASP.Net Webforms Application

I'm trying to use CKEditor in my Webforms application and I have tried many other methods without success. 我正在尝试在Webforms应用程序中使用CKEditor,但是我尝试了许多其他方法,但均未成功。 Can someone help? 有人可以帮忙吗? The site uses a Site.Master file which all the aspx files provide content for using content place-holders. 该站点使用Site.Master文件,所有aspx文件都提供使用内容占位符的内容。 So I place the JavaScript call in the ASPX rather than in the master file. 因此,我将JavaScript调用放置在ASPX中而不是主文件中。

I'm also trying to get it to edit in a content editable div element. 我也试图让它在内容可编辑div元素中进行编辑。 It works fine in a small test site but not in my application. 它在小型测试站点中可以正常工作,但在我的应用程序中却无法正常工作。 Any ideas? 有任何想法吗?

My Site.master has two content placeholders I want to use: 我的Site.master有两个我要使用的内容占位符:

<asp:ContentPlaceHolder ID="Scripts" runat="server" />
and
<asp:ContentPlaceHolder ID="MainContent" runat="server">

An then my aspx files have: 然后我的aspx文件有:

<asp:Content ID="Content3" ContentPlaceHolderID="Scripts" runat="server"> 
<script src="ckeditor/ckeditor.js"></script> 
</asp:Content>`

and

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <div id="renderTarget" renderwidth="1100"> </asp:Content> </asp:Content>

Somewhere in my JavaScript, I set the content editable of my renderTarget div to true. 在JavaScript的某个位置,我将renderTarget div的可编辑内容设置为true。

$(".contentbox[dynamic='true']").attr("contenteditable", "true");

And at this point, I expect CKedtor to add its controls to the div. 至此,我希望CKedtor将其控件添加到div中。 But It doesn't. 但事实并非如此。 i use the same process with TinyMCE and it works fine. 我对TinyMCE使用相同的过程,效果很好。

If you have CKEditor in your project correctly, it is as simple as: 如果您的项目中正确包含了CKEditor,则很简单:

<textarea cols="80" class="ckeditor" id="editor1" name="editor1" rows="10"></textarea>

or even 甚至

<div contenteditable="true">...</div>

Also, you may want to read up on jQuery Selectors . 另外,您可能想阅读jQuery Selectors

An example more like what you posted: 一个类似于您发布的示例:

<div id="ckMe">...</div>

<script>
    $(document).ready(function () {
        $("#ckMe").attr("contenteditable", "true");
    });
</script>

all you need is to install the version for asp.net in your project and then just use it as simple as adding a usercontrol: 您需要做的就是在项目中安装asp.net的版本,然后像添加用户控件一样简单地使用它:

<ckeditor:ckeditorcontrol ID="CkEditor1" runat="server"></ckeditor:ckeditorcontrol>

Documentation from ckEditor ckEditor的文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM