.net中ckeditor的应用

时间:2023-03-09 09:53:29
.net中ckeditor的应用

①js文件的引入

<script src="/public/ckeditor_4.4.7/ckeditor.js"></script>
<script src="/public/ckfinder_2.5.0/ckfinder.js"></script>

②javascript编写

<script type="text/javascript">
function BrowseServer() {
// You can use the "CKFinder" class to render CKFinder in a page:
var finder = new CKFinder();
finder.basePath = '/public/ckfinder_2.5.0/'; // The path for the installation of CKFinder (default = "/ckfinder/").
finder.selectActionFunction = SetFileField;
finder.popup();
}
function SetFileField(fileUrl) {
document.getElementById('TxtPictureUrl').value = fileUrl;
} $(document).ready(function () {
editor = CKEDITOR.replace('TxtContent');
CKFinder.setupCKEditor(editor, '/public/ckfinder_2.5.0/'); $("#BtnSave").click(function () {
//判断标题是否为空
if ($("#TxtTitle").val() == '') {
alert('请输入标题.');
$("#TxtTitle").focus();
return false;
} var content = editor.getData();
//判断内容是否为空
if (content == '') {
alert('请输入文章内容.');
return false;
}
});
});
</script>

③body加入TextBox显示ckeditor

  <td>
<asp:TextBox ID="TxtContent" runat="server" TextMode="MultiLine"></asp:TextBox>
</td>

④后台获取ckeditor的值

item.Content = TxtContent.Text;