1

J'ai codé mon propre système de devis car HtmlEditorExtender n'a pas de système de cotation. Ou l'a-t-il?HtmlEditorExtender supprime la balise pré

asp.net 4.5 et ASP.NET AJAX contrôle Toolkit 16.1.0.0

En 2016 ne nous ont toujours pas fonction de liste blanche?

Pour référence, j'utilise pré-tag. Cependant, la dernière version de HtmlEditorExtender dans la version 16.1.0 supprime la balise pre. Il supprime simplement la partie qui contient le pré-tag.

Je veux dire comme

<pre><pre>CeFurkan: Wrote</pre>dsfsdfs</pre> 

Ceci est enlevé du côté client avant de poster sur le serveur. Comment puis-je autoriser cette balise?

J'ai aussi essayé avec span class = "myClass" et supprime tag classe cette fois

mes paramètres sont

Code

derrière

htmlEditorExtender1.EnableSanitization = true; 

Code avant

<ajaxToolkit:HtmlEditorExtender ID="htmlEditorExtender1" TargetControlID="txtMessageBody" 
        runat="server" DisplaySourceTab="True"> 
        <Toolbar> 
         <ajaxToolkit:Undo /> 
         <ajaxToolkit:Redo /> 
         <ajaxToolkit:Bold /> 
         <ajaxToolkit:Italic /> 
         <ajaxToolkit:Underline /> 
         <ajaxToolkit:StrikeThrough /> 
         <ajaxToolkit:Subscript /> 
         <ajaxToolkit:Superscript /> 
         <ajaxToolkit:JustifyLeft /> 
         <ajaxToolkit:JustifyCenter /> 
         <ajaxToolkit:JustifyRight /> 
         <ajaxToolkit:JustifyFull /> 
         <ajaxToolkit:InsertOrderedList /> 
         <ajaxToolkit:InsertUnorderedList /> 
         <ajaxToolkit:CreateLink /> 
         <ajaxToolkit:UnLink /> 
         <ajaxToolkit:RemoveFormat /> 
         <ajaxToolkit:SelectAll /> 
         <ajaxToolkit:UnSelect /> 
         <ajaxToolkit:Delete /> 
         <ajaxToolkit:Cut /> 
         <ajaxToolkit:Copy /> 
         <ajaxToolkit:Paste /> 
         <ajaxToolkit:BackgroundColorSelector /> 
         <ajaxToolkit:ForeColorSelector /> 
         <ajaxToolkit:FontNameSelector /> 
         <ajaxToolkit:FontSizeSelector /> 
         <ajaxToolkit:Indent /> 
         <ajaxToolkit:Outdent /> 
         <ajaxToolkit:InsertHorizontalRule /> 
         <ajaxToolkit:HorizontalSeparator /> 
        </Toolbar> 
       </ajaxToolkit:HtmlEditorExtender> 

Et web config

<ajaxControlToolkit useStaticResources="true" renderStyleLinks="false" htmlSanitizer="AjaxControlToolkit.HtmlEditor.Sanitizer.DefaultHtmlSanitizer, AjaxControlToolkit.HtmlEditor.Sanitizer" /> 

l'erreur complète donne quand la réponse de Yuriy a essayé

Value cannot be null. 
Parameter name: type 
Stack: 
    at System.Activator.CreateInstance(Type type, Boolean nonPublic) 
    at System.Activator.CreateInstance(Type type) 
    at AjaxControlToolkit.HtmlEditorExtender.CreateSanitizer() 
    at System.Lazy`1.CreateValue() 
    at System.Lazy`1.LazyInitValue() 
    at System.Lazy`1.get_Value() 
    at AjaxControlToolkit.HtmlEditorExtender.get_Sanitizer() 
    at AjaxControlToolkit.HtmlEditorExtender.OnInit(EventArgs e) 
    at System.Web.UI.Control.InitRecursive(Control namingContainer) 
    at System.Web.UI.Control.InitRecursive(Control namingContainer) 
    at System.Web.UI.Control.InitRecursive(Control namingContainer) 
    at System.Web.UI.Control.InitRecursive(Control namingContainer) 
    at System.Web.UI.Control.InitRecursive(Control namingContainer) 
    at System.Web.UI.Control.InitRecursive(Control namingContainer) 
    at System.Web.UI.Control.InitRecursive(Control namingContainer) 
    at System.Web.UI.Control.InitRecursive(Control namingContainer) 
    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 

implémentation de la classe

enter image description here

Répondre

1

La façon la plus facile à mon avis, est de créer votre propre mise en œuvre de la IHtmlSanitizer héritant le DefaultHtmlSanitizer et remplacer la méthode GetSafeHtmlFragment comme ci-dessous

public class MyHtmlSanitizer : DefaultHtmlSanitizer, IHtmlSanitizer 
{ 
    private static readonly string[] whiteListTags = (ConfigurationManager.AppSettings["whiteListTags"] ?? "").Split(','); 

    string IHtmlSanitizer.GetSafeHtmlFragment(string htmlFragment, Dictionary<string, string[]> whiteList) 
    { 
     foreach (var tag in whiteListTags) 
     { 
      if (!whiteList.ContainsKey(tag)) 
       whiteList.Add(tag, new string[0]); 
     } 

     return base.GetSafeHtmlFragment(htmlFragment, whiteList); 

    } 
} 

Ensuite, ajoutez à la section appSettings web.config réglage pour mes propres tags liste blanche:

<appSettings> 
    <add key="whiteListTags" value="pre"/> 
</appSettings> 

et configurer boîte à outils pour utiliser ce désinfectant pour les mains au lieu de la valeur par défaut: ty très

<ajaxControlToolkit 
    useStaticResources="true" 
    renderStyleLinks="false" 
    htmlSanitizer="AjaxControlToolkit.Customization.MyHtmlSanitizer, AjaxControlToolkit.Customization" 
    tempFolder="~/Temp"/> 
+0

pour répondre mais il a donné l'erreur :(à System.Activator.CreateInstance (Type de type, Boolean nonPublic) à System.Activator.CreateInstance (Type de type) à AjaxControlToolkit.HtmlEditorExtender.CreateSanitizer() à System.Lazy'1.CreateValue() à System.Lazy'1.LazyInitValue() à System.Lazy'1.get_Value() à AjaxControlToolkit.HtmlEditorExtender.get_Sanitizer ( – MonsterMMORPG

+0

@MonsterMMORPG fix Nom de type dans ajaxControlToolkit.htmlSanitizer en fonction du nom du type de sanotozer personnalisé dans votre projet –

+0

Yuriy je n'ai pas de désinfectant personnalisé. J'ai implémenté celui par défaut. Aussi j'ai suivi votre réponse.Ajout d'une nouvelle classe exactement comme la vôtre, puis modification de la configuration web comme vous l'avez dit – MonsterMMORPG