你是用的ckeditor.net还是纯js的ckeditor
解决方案 »
- 和大家讨论一下项目开发的问题
- 求读取excel相应代码~~~
- FindCountrol指定一个控件的id,但实际上它却同时指定了2个,郁闷之极。
- 无法将类型“double”隐式转换为“System.Random”
- 哪里有VS.NET 2003 CD1下载啊?跪求。。。(有分)在线等
- 关于安装2003版的.net问题。。。。大家快来帮忙啊,眼睛都哭肿了。。。。。。。。。。
- 有什么书适合ASP初学者?
- entity framework无法用
- 如何将一个Flash设置为网页的背景
- 没学过ASP,直接学ASP.net行吗
- 帮忙看一下,这个是什么控件。
- aspx页面获取金额decimal,录入数据库字段decimal(18,2),转换错误问题
{
if(CKEDITOR.instances["Encroll_Regulation_Label_Content_Content"+i])//判断是否绑定
{
CKEDITOR.remove(CKEDITOR.instances["Encroll_Regulation_Label_Content_Content"+i]); //解除绑定
}
CKEDITOR.replace("Encroll_Regulation_Label_Content_Content"+i);//重新绑定
} 这是源码
{
CKEDITOR.instances["Encroll_Regulation_Label_Content_Content"+i].idestroy();
}
var ckobj=CKEDITOR.instances["Encroll_Regulation_Label_Content_Content"+i];
if(ckobj)//判断是否绑定
{
ckobj.destroy();
ckobj=null;
CKEDITOR.remove(ckobj);
}
CKEDITOR.instances["Encroll_Regulation_Label_Content_Content"+i].idestroy();
写错了多了个i
CKEDITOR.instances["Encroll_Regulation_Label_Content_Content"+i].destroy();
if(ckobj)//判断是否绑定
这块有错
{
protected void Page_Load(object sender, EventArgs e)
{
//得到的A_PAGE ID
string theID = "11111111"; string theCDEConfig = "var thefilebrowserUploadUrl = 'hw_test_ckeditor_upload.ashx?type=null'; \r\n";
theCDEConfig = theCDEConfig + "var thefilebrowserImageUploadUrl = 'hw_test_ckeditor_upload.ashx?type=image'; \r\n";
theCDEConfig = theCDEConfig + "var thefilebrowserFlashUploadUrl = 'hw_test_ckeditor_upload.ashx?type=flash'; \r\n";
theCDEConfig = theCDEConfig + "var thefileContextUploadUrl = 'hw_test_ckeditor_context_upload.ashx'; \r\n";
theCDEConfig = theCDEConfig + "var theAPageID = '" + theID + "'; \r\n";
Page.ClientScript.RegisterClientScriptBlock(typeof(string), "theCKEditorValue", theCDEConfig, true); Page.ClientScript.RegisterClientScriptInclude("getFilseJS", "hw_test_ckeditor_getfiles.ashx?id=" + theID); } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
TextBox1.Text = DropDownList1.SelectedValue;
Button1.PostBackUrl = "/SITE_DATA_SOURCE/site1/subsite1/artlcleclass1/2011-0" + DropDownList1.SelectedValue + "/hw_test_ckeditor.aspx";
string theJS = "window.onload = showCKEditor();";
Page.ClientScript.RegisterClientScriptBlock(typeof(string), "theCKEditorEdit", theJS, true);
}
前台<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="hw_test_ckeditor.aspx.cs" Inherits="ITCOA_CMS.UI.hw_test_ckeditor" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script type="text/javascript" src="CKEditor/ckeditor.js"></script>
<script type="text/javascript" src="js/jquery-1.4.4.min.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div>
a<br />
a<br /> <a />
<div id="CKEditorSpace"></div>
<asp:TextBox ID="CKEditorContext" runat="server" TextMode="MultiLine" style="visibility:hidden; display:none;">adfafasfaf</asp:TextBox>
<script type="text/javascript">
var theCKEditor;
function showCKEditor(){
CKEDITOR.on('instanceReady', function(evt){
var tempeditor = evt.editor;
var themaximize = tempeditor.getCommand( 'maximize' );
if(themaximize.state != CKEDITOR.TRISTATE_ON )
tempeditor.execCommand('maximize');
}); CKEDITOR.config.toolbar_itcoacmstb =
[
{ name: 'document', items : [ 'Source','-','SaveUp','NewPage','DocProps','Preview','Print','-','Templates' ] },
{ name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },
{ name: 'editing', items : [ 'Find','Replace','-','SelectAll','-','SpellChecker', 'Scayt' ] },
{ name: 'forms', items : [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField' ] },
'/',
{ name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] },
{ name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','CreateDiv','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl' ] },
{ name: 'links', items : [ 'Link','Unlink','Anchor' ] },
{ name: 'insert', items : [ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak' ] },
'/',
{ name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] },
{ name: 'colors', items : [ 'TextColor','BGColor' ] },
{ name: 'tools', items : [ 'Close', 'ShowBlocks','-','About' ] }
]; if(theCKEditor==null)
{
var theContextStr = document.getElementById("CKEditorContext").value;
theContextStr = "";
theCKEditor = CKEDITOR.appendTo('CKEditorSpace',{
extraPlugins : 'itcoacms_close,itcoacms_save',
toolbar : 'itcoacmstb',
// filebrowserBrowseUrl : '/ckfinder/ckfinder.html',
// filebrowserImageBrowseUrl : 'a_page_getfile.?type=Images',
// filebrowserFlashBrowseUrl : 'a_page_getfile.?type=Flash',
filebrowserUploadUrl : thefilebrowserUploadUrl,
filebrowserImageUploadUrl : thefilebrowserImageUploadUrl,
filebrowserFlashUploadUrl : thefilebrowserFlashUploadUrl
},theContextStr);
addUploadButton(theCKEditor);
}
}function addUploadButton(theCKEditor){
CKEDITOR.on('dialogDefinition', function( ev ){
var dialogName = ev.data.name;
var dialogDefinition = ev.data.definition;
if ( dialogName == 'image' ){
var infoTab = dialogDefinition.getContents( 'Upload' );
infoTab.add({
type : 'select',
id : 'EX_select_image',
align : 'center',
label : '选择已有图片',
size: 5,
width: '150px',
items : ArrayFiles,
'default' : 'images1.jpg'
}, ''); //place front of the browser button
infoTab.add({
type : 'button',
id : 'EX_select_image_button',
align : 'center',
label : '选择',
onClick : function( evt ){
var thisDialog = this.getDialog();
var txtUrlObj = thisDialog.getContentElement('info', 'txtUrl');
var txtUrlObjID = txtUrlObj.getInputElement().$.id;
var urlObj = document.getElementById(txtUrlObjID);
var EX_select_imageObj = thisDialog.getContentElement('Upload', 'EX_select_image');
var EX_select_imageObjID = EX_select_imageObj.getInputElement().$.id;
var selectObj = document.getElementById(EX_select_imageObjID);
urlObj.value = selectObj.options[selectObj.selectedIndex].value;
urlObj.fireEvent("onchange"); //触发url文本框的onchange事件,以便预览图片
}
}, ''); //place front of the browser button
}
});
}function closeCKEditor(){
if(theCKEditor!=null)
{
theCKEditor.destroy();
theCKEditor = null;
}
}</script>
<%--<input type="button" value="edit" id="edit" onclick="javascript:showCKEditor();" />--%><input type="button" value="close" id="close" onclick="javascript:closeCKEditor();" />
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" Text="edit" PostBackUrl="~/hw_test_ckeditor.aspx" />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
a<br />
</div>
</form>
</body>
</html>
<textarea id=\"Encroll_Regulation_Label_Content_Content" + i + "\" name=\"Encroll_Regulation_Label_Content_Content" + i + "\" cols='20' rows='2'></textarea>
for(var i=0;i<parseInt(num);i++)
{
CKEDITOR.replace("Encroll_Regulation_Label_Content_Content"+i);//重新绑定
}
});
简单吧!!!
Page.ClientScript.RegisterClientScriptInclud("getFilseJS", "hw_test_ckeditor_getfiles.ashx?id=" + theID);
我是看你这个想到的。。我重新加载一下脚本文件。。这样不管你绑定不绑定都清空了!
你看是这个道理吗
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script type="text/javascript" src="CKEditor/ckeditor.js"></script>
<script type="text/javascript" src="js/jquery-1.4.4.min.js"></script>
</head>
<body>
<form id="form1" runat="server">
<textarea cols="15" row="10" id="CKEditorSpace"></textarea>
<textarea cols="15" row="10" id="CKEditorContext" >adfafasfaf</textarea>
<script type="text/javascript">
var theCKEditor;
function showCKEditor(){
theCKEditor = CKEDITOR.replace('CKEditorSpace');
}
function closeCKEditor(){
if(theCKEditor!=null)
{
theCKEditor.destroy();
theCKEditor = null;
}
}
</script>
<input type="button" value="edit" id="edit" onclick="javascript:showCKEditor();" />
<input type="button" value="close" id="close" onclick="javascript:closeCKEditor();" /></div>
</form>
</body>
</html>
这行没用
当下拉框变化的时候。又是另一个Encroll_Regulation_Label_Content_Content0,Encroll_Regulation_Label_Content_Content1
第一次加载已经绑定进去了。。所以第二次再加载的话。。就有问题了,所以就要解除绑定。。然后再重新绑定
// 按下自定义按钮时执行的代码
var saveCmd =
{
exec : function( editor )
{
//Ajax上传内容
var theHtml = editor.getData();
var theTime = new Date();
var theMarkStr = theTime.toString() + Math.random();
var backhtml = $.ajax({
url: thefileContextUploadUrl,
data:{context : theHtml, apageid : theAPageID, str : theMarkStr},
async: false
}).responseText;
if(backhtml == "OK")
{
alert("保存成功!");
}
else
{
alert("保存失败!");
}
}
}; var pluginName = 'itcoacms_save'; // Register a plugin named "itcoacms_save".
CKEDITOR.plugins.add( pluginName,
{
init : function( editor )
{
var command = editor.addCommand( pluginName, saveCmd );
editor.ui.addButton( 'SaveUp',
{
label:'保存',
icon: this.path + 'icon.gif',
command: pluginName
});
}
});
})();
$.ajax({
type:"post",
url:"../Encroll/Encroll_do.aspx",
data:"action=EncrollTable&state="+i,
success:function(msg){
if(msg!=null && msg!=""){
$("#frm_optitem_2").append(msg.split('$')[0]);
$("#Num").val(msg.split('$')[1]);
loadfck(msg.split('$')[1]);
}
}
})
我还要进行清空。再加载
$("#Encroll_Regulation_Type").change(function(){
$("#frm_optitem_2 tr").remove();
ajaxfck($(this).val());
if($(this).val()=="-1")
{
$("#frm_optitem_2").append("<tr><td><span style='color:Red'>是否选择了教育类型</span></td></tr>");
}
})
<head runat="server">
<title>无标题页</title>
<script type="text/javascript" src="CKEditor/ckeditor.js"></script>
<script type="text/javascript" src="js/jquery-1.4.4.min.js"></script>
</head>
<body>
<form id="form1" action="hw_test1.ashx" method="post">
<textarea cols="15" row="10" id="CKEditorSpace" name="CKEditorSpace"></textarea>
<script type="text/javascript">
var theCKEditor;
function showCKEditor(){
theCKEditor = CKEDITOR.replace('CKEditorSpace');
}
function closeCKEditor(){
if(theCKEditor!=null)
{
theCKEditor.destroy();
theCKEditor = null;
}
}
</script>
<input type="button" value="edit" id="edit" onclick="javascript:showCKEditor();" />
<input type="button" value="close" id="close" onclick="javascript:closeCKEditor();" />
<input type="submit" value="submit" id="submit" />
</div>
</form>
</body>
</html>
这个不是问题我所有的都带有name
这个不是问题我所有的都带有name