gpt4 book ai didi

javascript - 没有在tinyMCE编辑器中获得更新的测试

转载 作者:行者123 更新时间:2023-11-28 09:09:23 24 4
gpt4 key购买 nike

我正在使用tinyMCE在我的asp.net站点中显示编辑器以添加和编辑文章功能。我的代码如下

<script type="text/javascript" language="javascript">        

tinyMCE.init({
// General options
mode: "exact",
elements: '<%=txtTextBox.ClientID%>',
theme: "advanced",
width: "650",
height: "500",
plugins: "style,advhr,advimage,advlink,inlinepopups,preview,media,searchreplace,contextmenu,paste,noneditable,visualchars,nonbreaking,wordcount",
// Theme options
theme_advanced_buttons1: "undo,redo,separator,bold,italic,underline,separator,cut,copy,paste,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,outdent,indent,separator,image,media,link,separator,forecolor,backcolor,separator,preview",
theme_advanced_buttons2: "fontsizeselect,fontselect",
theme_advanced_buttons3: "",
theme_advanced_font_sizes : "10px,12px,14px,16px,24px",
theme_advanced_toolbar_location: "top",
theme_advanced_toolbar_align: "left",
theme_advanced_statusbar_location: "bottom",
theme_advanced_resizing: false,
relative_urls: true,
remove_script_host: true,
document_base_url: ""
});

</script>



<div>
<textarea id="txtTextBox" runat="server" cols="500" rows="100"></textarea>
<asp:Button ID="Button1" runat="server" Text="Save" OnClick="Button1_Click" />
<asp:Button ID="Button2" runat="server" Text="Update" OnClick="Button2_Click" OnClientClick="return test();" />
</div>

此代码将在数据库编辑器中输入的任何内容添加为 HTML。这很好用。为了编辑,我只是​​检索这篇文章记录并将内容显示在 页面加载时的文本框

   string sql = "select * from content_table where ID=1";
comm = new SqlCommand(sql, conn);
da = new SqlDataAdapter(comm);
DataSet ds = new DataSet();
da.Fill(ds);

if (ds != null)
{
txtTextBox.InnerText = Server.HtmlDecode(ds.Tables[0].Rows[0]["Content"].ToString());
}

但问题是我没有得到新的更改文本,而是只得到页面加载时得到的文本。为什么会发生这种情况。有什么建议吗?

最佳答案

因为您正在更新文本区域 - 而不是编辑器。对于此用途:

var new_content = Server.HtmlDecode(ds.Tables[0].Rows[0]["Content"].ToString();
tinymce.get('your_editor_id').setContent(new_content); // editorid equals your textarea id

关于javascript - 没有在tinyMCE编辑器中获得更新的测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16518361/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com