gpt4 book ai didi

asp.net - 我第一次保存时 TinyMCE 不返回任何值

转载 作者:行者123 更新时间:2023-12-04 12:14:57 25 4
gpt4 key购买 nike

我的 ASP.NET 页面上有一个 TinyMCE 脚本,并且在函数 SaveFAQ() 的帮助下我们可以保存 TineMCE 使用的文本区域。

private void SaveFAQ(bool returnToFAQ = false)
{
DataSet ds = new DataSet();

if (mceQuestion.Value.Length > 7)
if (mceQuestion.Value.Substring(0, 3) == "<p>" && "</p>" == mceQuestion.Value.Substring(mceQuestion.Value.Length - 4, 4))
{
mceQuestion.Value = mceQuestion.Value.Substring(3, mceQuestion.Value.Length - 7);
}

DateTime? faqFromDate;
DateTime tmp;
if (DateTime.TryParse(txtQuestionOfTheDay.Text, out tmp))
faqFromDate = tmp;
else
faqFromDate = null;

ds = _server.AdminSaveFAQ(FAQ_Id, chbHighlight.Checked, LAN_Id_Primary, mceQuestion.Value, mceAnswer.Value, txtFlash.Text, mceStepByStep.Value, mceTip.Value, faqFromDate, chbImportant.Checked);

if (FAQ_Id == 0)
FAQ_Id = (int)ds.Tables[0].Rows[0]["FAQ_Id"];

foreach (Control c in pnlCheckbox.Controls)
{
if (c.GetType() == typeof(CheckBox))
_server.AdminSaveFAQCategory(FAQ_Id, int.Parse(((CheckBox)c).ID), ((CheckBox)c).Checked);
}

if (!returnToFAQ)
{
lblStatusUp.Visible = true;
lblStatusDown.Visible = true;

if (!ds.DataSetEmpty())
{
lblStatusUp.Text = "Saved successfully!";
lblStatusDown.Text = "Saved successfully!";
lblStatusUp.ForeColor = System.Drawing.Color.Green;
lblStatusDown.ForeColor = System.Drawing.Color.Green;
}
else
{
lblStatusDown.Text = "Error while saving!";
lblStatusUp.Text = "Error while saving!";
lblStatusUp.ForeColor = System.Drawing.Color.Red;
lblStatusDown.ForeColor = System.Drawing.Color.Red;
}
}
else
{
//if (Session["PreviousPage"] != null) Response.Redirect(Session["PreviousPage"].ToString());
Response.Redirect("~/Administration/FAQ.aspx");
}
}

我第一次按下保存按钮时,它会触发一个执行此函数的事件 SaveFAQ(); .它成功地在数据库中创建了一行,但字符串 mceQuestion.Value & mceAnswer.Value是空的。我第二次按下按钮时,它会触发完全相同的事件,并填充值并成功保存。

我该怎么做才能只按一次保存?

感谢所有答案,祝您有美好的一天!

编辑:
这是 mceQuestion;
<textarea ID="mceQuestion" runat="server" cols="100" rows="6" />

编辑 2:
一直试图将这种节省与新闻的保存(完全有效)进行比较。没有太大的差异,我一直在测试这个 SaveFAQ() 上的差异。但这并没有削减它。

如果它们可能派上用场,这是我的 TinyMCE 设置。
<script type="text/javascript">
tinyMCE.init({
// General options
mode: "textareas",
theme: "advanced",
plugins: "autolink,lists,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

// Theme options
theme_advanced_buttons1: ",bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
theme_advanced_buttons2: "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
theme_advanced_buttons3: "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
theme_advanced_buttons4: "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage",
theme_advanced_toolbar_location: "top",
theme_advanced_toolbar_align: "left",
theme_advanced_statusbar_location: "bottom",
theme_advanced_resizing: true,

// Skin options
skin: "o2k7",
skin_variant: "silver",

// Example content CSS (should be your site CSS)
//content_css: "css/example.css",

// Drop lists for link/image/media/template dialogs
template_external_list_url: "js/template_list.js",
external_link_list_url: "js/link_list.js",
external_image_list_url: "Images.aspx",
media_external_list_url: "js/media_list.js",

// Replace values for the template plugin
//template_replace_values: {
// username: "Some User",
// staffid: "991234"
//}
});
</script>

我感谢任何可能或确实引导我走向正确方向的反馈、答案或提示!

最佳答案

我通过添加 OnClientClick="tinyMCE.triggerSave(false,true);" 来修复它到每个保存按钮。

关于asp.net - 我第一次保存时 TinyMCE 不返回任何值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17399872/

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