2020年9月18日 星期五

[研究][ASP.NET][WebForm] AjaxControlToolkit 20.1.0 WYSIWYG HTML Editor 試用(NuGet)

[研究][ASP.NET][WebForm] AjaxControlToolkit 20.1.0 WYSIWYG HTML Editor 試用(NuGet)

2020-09-18

WYSIWYG HTML Editor = 所見即所得 HTML 網頁編輯器

WYSIWYG = What You See Is What You Get 

參考

如何使用 HTML 編輯器控制項? (C#)

https://docs.microsoft.com/zh-tw/aspnet/web-forms/overview/ajax-control-toolkit/htmleditor/how-do-i-use-the-html-editor-control-cs

HTMLEditorExtender Sample

https://ajaxcontroltoolkit.devexpress.com/HtmlEditorExtender/HtmlEditorExtender.aspx

GitHub - DevExpress/AjaxControlToolkit: The ASP.NET AJAX Control Toolkit is a classic set of ASP.NET WebForms extensions.

https://github.com/DevExpress/AjaxControlToolkit

HtmlEditorExtender 程式範例

https://github.com/DevExpress/AjaxControlToolkit/blob/master/AjaxControlToolkit.SampleSite/HtmlEditorExtender/HtmlEditorExtender.aspx

AjaxControlToolkit 所有範例

https://github.com/DevExpress/AjaxControlToolkit/tree/master/AjaxControlToolkit.SampleSite

環境 Visual Studio 2019 + ASP.NET + WebForm ( Web Application )














********************************************************************************

'/' 應用程式中發生伺服器錯誤。

The Sanitizer is not configured in the web.config file. Either install the AjaxControlToolkit.HtmlEditor.Sanitizer NuGet package or set the EnableSanitization property to False (insecure). 

 描述: 在執行目前 Web 要求的過程中發生未處理的例外狀況。請檢閱堆疊追蹤以取得錯誤的詳細資訊,以及在程式碼中產生的位置。 

 例外狀況詳細資訊: System.Exception: The Sanitizer is not configured in the web.config file. Either install the AjaxControlToolkit.HtmlEditor.Sanitizer NuGet package or set the EnableSanitization property to False (insecure).

原始程式錯誤: 

在執行目前 Web 要求期間,產生未處理的例外狀況。如需有關例外狀況來源與位置的資訊,可以使用下列的例外狀況堆疊追蹤取得。   

堆疊追蹤: 

[Exception: The Sanitizer is not configured in the web.config file. Either install the AjaxControlToolkit.HtmlEditor.Sanitizer NuGet package or set the EnableSanitization property to False (insecure).]

   AjaxControlToolkit.HtmlEditorExtender.OnInit(EventArgs e) +840

   System.Web.UI.Control.InitRecursive(Control namingContainer) +142

   System.Web.UI.Control.InitRecursive(Control namingContainer) +318

   System.Web.UI.Control.InitRecursive(Control namingContainer) +318

   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +416

版本資訊: Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.8.4210.0 

********************************************************************************





Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" 
    Inherits="AJAXControlToolkitTest.Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1" runat="server" />
            <asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" Rows="10" Columns="80">
            </asp:TextBox>
            <ajaxToolkit:HtmlEditorExtender ID="HtmlEditorExtender1" TargetControlID="TextBox1" 
                runat="server"></ajaxToolkit:HtmlEditorExtender>
            <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /><br />
            <asp:Literal ID="Literal1" runat="server"></asp:Literal>
        </div>
    </form>
</body>
</html>


Default.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace AJAXControlToolkitTest
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Literal1.Text = TextBox1.Text;
        }
    }
}

********************************************************************************
它必須使用 AJAX,否則執行會出現下面錯誤

A ScriptManager is required on the page to use ASP.NET AJAX Script Components.

********************************************************************************

(完)

沒有留言:

張貼留言