跳到主要內容

[MVC] CKEditor

//官網下載:http://ckeditor.com/download
Nuget 套件管理工具下載:搜尋 HtmlSanitizationLibrary

//.cshtml
[View]

 @using (Html.BeginForm("functionname", "MyBlog", FormMethod.Post, new { id = "FormNew" }))

    {

 @Html.TextAreaFor(model => model.content, new { id = "content", @name = "content" })
 <script type="text/javascript">
            CKEDITOR.replace('content', { width: '800px' });
 </script>

}

//MyBlogController.cs
[Controller]

[HttpPost]    
[ValidateInput(false)]      //解決html1編碼問題
public ActionResult functionname(string Title, string content)   //Title,content自動對應到html的id
{
int RtnCode = m.MyDataEdit(AID, Sanitizer.GetSafeHtmlFragment(Title),Sanitizer.GetSafeHtmlFragment( content));
}

於VS2010就可以透過NuGet幫網站專案安裝上 AntiXSS
程式中使用AntiXSS的 Sanitizer.GetSageHtmlFragement() 方法,取得安全的HTML區段內容。

參考連結:
ASP.NET MVC 3 使用 CKEditor




[config 全部可編輯的ToorBar功能]

config.toolbar = 'Full';
 
config.toolbar_Full =
[
 { name: 'document', items : [ 'Source','-','Save','NewPage','DocProps','Preview','Print','-','Templates' ] },
 { name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },
 { name: 'editing', items : [ 'Find','Replace','-','SelectAll','-','SpellChecker', 'Scayt' ] },
 { name: 'forms', items : [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 
        'HiddenField' ] },
 '/',
 { name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] },
 { name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','CreateDiv',
 '-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl' ] },
 { name: 'links', items : [ 'Link','Unlink','Anchor' ] },
 { name: 'insert', items : [ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe' ] },
 '/',
 { name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] },
 { name: 'colors', items : [ 'TextColor','BGColor' ] },
 { name: 'tools', items : [ 'Maximize', 'ShowBlocks','-','About' ] }
];

參考連結:
---------------------------------------------------------------------

自訂版


config.toolbar = 'Cunstomer';


    config.toolbar_Cunstomer =
    [
        { name: 'document', items: ['Source', '-', 'Save', 'NewPage', 'DocProps', 'Preview', 'Print', '-', 'Templates'] },
        { name: 'clipboard', items: ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo'] },
        { name: 'editing', items: ['Find', 'Replace'] },
        { name: 'insert', items: ['Image', 'Flash', 'Table', 'Smiley', 'SpecialChar', '-', 'Link', 'Unlink'] },
        '/',
        { name: 'styles', items: ['Font', 'FontSize'] },
        { name: 'colors', items: ['TextColor', 'BGColor'] },
        { name: 'basicstyles', items: ['Bold', 'Italic', 'Underline', 'Strike', '-', 'RemoveFormat'] },
        { name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv'] },
        { name: 'align', items: ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'] }
    ];


留言

這個網誌中的熱門文章

[python] python 時區轉換 ( timezone )

python 時區轉換 import datetime as dt import pytz d = dt.datetime(2019,1,1,14,0,0) #create Taipei timezone tw = pytz.timezone('Asia/Taipei') #set d timezone is 'Asia/Taipei' twdt = tw.localize(d) #change to utc time utc_dt = twdt.astimezone(pytz.utc) *注意 網路上很多使用 d.replace(tzinfo=tw)   但是可能會出現時差問題, 如下: datetime.time(23, 18, 5, tzinfo=<DstTzInfo 'Asia/Shanghai' LMT+8:06:00 STD>) 參考文件 python时区设置——pytz模块

[HTML] 文字浮水印效果 text watermark css

[.css] .info-mask {     height: 0;       position: absolute;       margin-top:120px;   } .info-opacity {     opacity: 0.8;     color: black; } .info-text {     color: gray;     font-size: 40px;     -webkit-transform: rotate(-5deg);       line-height: 60px;     max-width:1200px;     letter-spacing:3px;     padding-left:0.8em; } [.html]     <div class="info-mask">         <p class="info-text">             WaterMarkText         </p>     </div>    <table class="table table-bordered table-striped table-responsive table-hover" style="position:                 relative;" >        <tbody class="info-opacity" >        </tbody>    </table>

[Linux] 解決 unix ///tmp/supervisor.sock no such file

supercisor run  一段時間系統會自動刪除tmp內的檔案, 這時候就會出現以下問題: unix ///tmp/supervisor.sock no such file 作業環境: Centos 7 *解決方法 修改 supervisor 設定檔 [...]#  vim /etc/supervisor/supervisord.conf [unix_http_server] file= /var/run/ supervisor.sock  ... [supervisord] logfile= /var/log/ supervisord.log ... [supervisorctl] serverurl=unix:/// var/run/ supervisor.sock 重新執行supervisor  關閉supervisor相關進程 [...]#  ps -ef | grep supervisord   [...]#  kill (進程id) 重新執行supervisor [...]# supervisord or [...]# supervisord -c /etc/supervisor/supervisord.conf 參考連結 解决unix:///tmp/supervisor.sock no such file的问题