1

記事の追加および編集機能のために、asp.net サイトでエディターを表示するために tinyMCE を使用しています。私のコードは次のとおりです

<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>  

このコードは、エディターで入力されたものを db に 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());
   }

しかし、問題は、ページの読み込み時に取得したテキストのみを取得する代わりに、新しい変更されたテキストを取得していないことです。なぜこれが起こっているのか。なにか提案を?

4

1 に答える 1