从数据库填充 CKEditor / Tinymce 时更新面板不起作用
Updatepanels not working when filling the CKEditor / Tinymce from the Database
我正在使用 ASP.NET 开发网站,我正在使用 CKEditor 作为富文本框。那里一切正常。
我正在使用这段代码来实现它
<asp:TextBox ID="txtDescription" runat="server" Width="100%" TextMode="MultiLine" Rows="15" AutoComplete="off" ClientIDMode="Static" MaxLength="6000"></asp:TextBox><br />
<script src="//cdn.ckeditor.com/4.5.3/basic/ckeditor.js"></script>
<script type="text/javascript">
window.onload = function () {
CKEDITOR.replace('txtJobDescription');
CKEDITOR.config.htmlEncodeOutput = true;
};
</script>
所以一切正常 fine.When 我保存了我正在使用的文本框的内容
HttpUtility.HtmlDecode(txtDescription.Text)
去做。
问题是当我从数据库中读取保存的文本并将其分配给 Ckeditor 文本框时,该页面中的所有更新面板都无法正常工作。(工作正常)
要分配它,我正在使用此代码。
DataTable dt=new DataTable
dt = objBLL.Get();
txtName=Text= dt.Rows[0]["name"].ToString();
txtDescription.Text = dt.Rows[0]["description"].ToString();
如果我评论最后一条语句,所有更新面板都可以正常工作。
我也用 tinymce 试过这个。问题是一样的。
我的代码有什么问题?
我正在回答我自己的问题。
您可以在页面级别设置页面 ValidateRequest=off。但这将使其他文本框也 post HTML 内容。
因此要避免在特定控件中使用 ValidateRequestMode=disabled。
这将只允许选定的控件 post 将 HTML 标记发送到服务器。
我正在使用 ASP.NET 开发网站,我正在使用 CKEditor 作为富文本框。那里一切正常。
我正在使用这段代码来实现它
<asp:TextBox ID="txtDescription" runat="server" Width="100%" TextMode="MultiLine" Rows="15" AutoComplete="off" ClientIDMode="Static" MaxLength="6000"></asp:TextBox><br />
<script src="//cdn.ckeditor.com/4.5.3/basic/ckeditor.js"></script>
<script type="text/javascript">
window.onload = function () {
CKEDITOR.replace('txtJobDescription');
CKEDITOR.config.htmlEncodeOutput = true;
};
</script>
所以一切正常 fine.When 我保存了我正在使用的文本框的内容
HttpUtility.HtmlDecode(txtDescription.Text)
去做。
问题是当我从数据库中读取保存的文本并将其分配给 Ckeditor 文本框时,该页面中的所有更新面板都无法正常工作。(工作正常) 要分配它,我正在使用此代码。
DataTable dt=new DataTable
dt = objBLL.Get();
txtName=Text= dt.Rows[0]["name"].ToString();
txtDescription.Text = dt.Rows[0]["description"].ToString();
如果我评论最后一条语句,所有更新面板都可以正常工作。 我也用 tinymce 试过这个。问题是一样的。 我的代码有什么问题?
我正在回答我自己的问题。
您可以在页面级别设置页面 ValidateRequest=off。但这将使其他文本框也 post HTML 内容。
因此要避免在特定控件中使用 ValidateRequestMode=disabled。
这将只允许选定的控件 post 将 HTML 标记发送到服务器。