2017-06-20 82 views
0

我嘗試添加TinyMCE到我的文本框中使用多行屬性AddMemo.aspx頁面,它是成功的。這是我在我的頁面的JavaScript sintax:在datagridview中顯示TinyMCE內容c#asp.net

<script type="text/javascript"> 
    tinyMCE.init({ 
     mode : "textareas", 
     theme : "advanced", 
     plugins : "safari,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,imagemanager,filemanager", 
     theme_advanced_buttons1 : "save,newdocument,|,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 : false, 
     template_external_list_url : "js/template_list.js", 
     external_link_list_url : "js/link_list.js", 
     external_image_list_url : "js/image_list.js", 
     media_external_list_url : "js/media_list.js" 
    }); 
</script> 

這裏我們圖片:

enter image description here

當點擊提交按鈕,它會被保存到數據庫中。我不知道如何顯示TiniMCE內容sintax到我的DataGridview(我使用綁定源)在HistoryMemo.aspx。 下面結果: enter image description here

任何人都可以幫我從數據庫TiniMCE內容顯示給我datagridview的我會欣賞它?

回答

0

如果從數據庫到您的datagridview你想告訴TinyMCE的內容,此代碼只是添加到您的datagriview頁面在你的datagridview所有列進行解碼HTML:

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) 
     { 
      if (e.Row.RowType == DataControlRowType.DataRow) 
      { 
       for (int i = 0; i < e.Row.Cells.Count; i++) 
       { 
        string encoded = e.Row.Cells[i].Text; 
        e.Row.Cells[i].Text = Context.Server.HtmlDecode(encoded); 
       } 
      } 
     } 

,如果你想解碼到spesific柱(前。第一欄)添加此代碼:

if (e.Row.RowType == DataControlRowType.DataRow) 
{ 
    string decodedText = HttpUtility.HtmlDecode(e.Row.Cells[0].Text); 
    e.Row.Cells[0].Text = decodedText; 
} 

您可以根據您的需要進行定製。

0

我相信你需要使用@Html.Raw來阻止.NET逃離你的HTML。

+0

「@ Html.Raw」在asp.net webform中工作嗎? – aminvincent