?
1.先看一下完善的代碼,也就是最終的答案!
functionGetContent(){
returnCKEDITOR.instances.nEditor.getData();//這里nEditor是textarea的name值
}
$("#btnAdd").click(function(){
//alert(GetContent());//測試使用
vardata=$("#fContent").serialize();
// alert(data);
$.Ajax(targetUrl,{
data:data+"&nEditor="+GetContent(),
type:"post",
dataType:"json",
success:function(jsonObj){
aspx";
},1);
}
});
});
<asp:ContentID="Content2"ContentPlaceHolderID="placeRight"runat="server">
<formid="fContent">
<%if (modNews!=null)
{%>
<inputtype="hidden"name="NID"value="<%=modNews.NID%>"/>
<%} %>
<strong>標題:<inputtype="text"name="nTitle"<%if (modNews==null){%>value=""<%}
else
{%>value="<%=modNews.NTitle%>"/><%} %>
</strong>
<strong>所屬分類:<selectid="NcId"name="NcId"><%=MakeSelect() %></select></strong>
</form>
<textareaid="nEditor"name="nEditor">
<%if(modNews!=null) {Response.Write(modNews.NContent);}%>
</textarea>
<divstyle="float: left; margin-left: 40%; margin-right: 20px;">
<inputtype="button"id="btnAdd"value="保存并提交 "style="font-size: large"/>
</div>
<div>
<inputtype="button"id="btnCancel"value="放棄編輯 "style="font-size: large"/>
</div>
</asp:Content>
?
2.以上結果是在幾個小時的折磨之后才得出來的,程序猿不容易?。】蛇@個期間會經過很多彎路,請看下面:
? ? 2.1一開始是這樣:textarea標簽在form表單內,直接用Jquery中的serialize()序列化;
$("#btnAdd").click(function(){
//alert(GetContent());//測試使用
vardata=$("#fContent").serialize();//注意這一行
// alert(data);
$.ajax(targetUrl,{
data:data+"&nEditor="+GetContent(),//注意這一行
type:"post",
dataType:"json",
success:function(jsonObj){
ProcessData(jsonObj,function(){
msgBox.showMsgOk(jsonObj.msg);
window.location="news.aspx";
},1);
}
});
});
<formid="fContent">
<%if (modNews!=null)
{%>
<inputtype="hidden"name="NID"value="<%=modNews.NID%>"/>
<%} %>
<strong>標題:<inputtype="text"name="nTitle"<%if (modNews==null){%>value=""<%}
else
{%>value="<%=modNews.NTitle%>"/><%} %>
</strong>
<strong>所屬分類:<selectid="NcId"name="NcId"><%=MakeSelect() %></select></strong>
<textareaid="nEditor"name="nEditor">/*textarea是在form表單里面的哦*/
<%if(modNews!=null) {Response.Write(modNews.NContent);}%>
</textarea>
</form>
?
? ? ? ? 2.2可是結果很悲催啊,當我新添加一條新聞時,我明明填寫了新聞標題和內容,為什么提示為空呢?難道被Web黑洞吸收了?我不相信,抱著堅定的信心尋找原因;

?
*************************************************
期間是艱難的思考期,撒尿的時候突然想到,textarea中的文本可能不能被serialize()序列化吧?
************************************************
? ? ? ? 2.3我繼續嘗試了一下編輯新聞,"哈哈哈"是從數據庫中讀取到的內容,我新添加了一句之后,點
新聞熱點
疑難解答