2011-10-19 42 views
0

我在ASP.Net中的項目C#編譯和運行正常,除了當我嘗試加載一個具有Ajax控件工具包HTMLEditorExtender的特定頁面。我得到一個密鑰不能爲空頁錯誤。我嘗試刪除htmleditorextender並放置一個asynchfileupload控件,而不是僅僅爲了確保scriptmanager正在工作,並且頁面正常運行並且上傳控件可以工作。所以這與htmleditorextender具體有關。下面是我的代碼有:HTMLEditorExtender導致'密鑰不能爲空'錯誤

<asp:TextBox ID="txtMailMsgContent" TextMode="MultiLine" runat="server"/> 
<cc1:HtmlEditorExtender ID="HTMLEditorExtender" runat="server" 
TargetControlID="txtMailMsgContent"> 

      <Toolbar> 
       <cc1:Undo /> 
       <cc1:Redo /> 
       <cc1:Bold /> 
       <cc1:Italic /> 
       <cc1:Underline /> 
       <cc1:StrikeThrough /> 
       <cc1:Subscript /> 
       <cc1:Superscript /> 
       <cc1:JustifyLeft /> 
       <cc1:JustifyCenter /> 
       <cc1:JustifyRight /> 
       <cc1:JustifyFull /> 
       <cc1:InsertOrderedList /> 
       <cc1:InsertUnorderedList /> 
       <cc1:CreateLink /> 
       <cc1:UnLink /> 
       <cc1:RemoveFormat /> 
       <cc1:SelectAll /> 
       <cc1:UnSelect /> 
       <cc1:Delete /> 
       <cc1:Cut /> 
       <cc1:Copy /> 
       <cc1:Paste /> 
       <cc1:BackgroundColorSelector /> 
       <cc1:ForeColorSelector /> 
       <cc1:FontNameSelector /> 
       <cc1:FontSizeSelector /> 
       <cc1:Indent /> 
       <cc1:Outdent /> 
       <cc1:InsertHorizontalRule /> 
       <cc1:HorizontalSeparator /> 
      </Toolbar> 
     </cc1:HtmlEditorExtender> 

,顯示頁面錯誤的錯誤行是這一個:

<cc1:HtmlEditorExtender ID="HTMLEditorExtender" runat="server" TargetControlID="txtMailMsgContent"> 

這是堆棧跟蹤:

[ArgumentNullException: Key cannot be null. 
Parameter name: key] 
    System.Collections.Hashtable.get_Item(Object key) +9355627 
    AjaxControlToolkit.Sanitizer.Sanitizer.Initialize() +163 
    AjaxControlToolkit.HtmlEditorExtender..ctor() +54 
    ASP.mail_emailmessage_aspx.__BuildControlHTMLEditorExtender() in c:\Inetpub\wwwroot\Mail\EMailMessage.aspx:111 
    ASP.mail_emailmessage_aspx.__BuildControlformMailMessage() in c:\Inetpub\wwwroot\Mail\EMailMessage.aspx:84 
    ASP.mail_emailmessage_aspx.__BuildControlTree(mail_emailmessage_aspx __ctrl) in c:\Inetpub\wwwroot\Mail\EMailMessage.aspx:1 
    ASP.mail_emailmessage_aspx.FrameworkInitialize() in c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\26676eb7\92c7e946\App_Web_kemmoois.0.cs:0 
    System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +54 
    System.Web.UI.Page.ProcessRequest() +78 
    System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21 
    System.Web.UI.Page.ProcessRequest(HttpContext context) +49 
    ASP.mail_emailmessage_aspx.ProcessRequest(HttpContext context) in c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\26676eb7\92c7e946\App_Web_kemmoois.0.cs:0 
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +100 
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75 

任何幫助會大大appreaciated。我試着用Google搜索這個錯誤,並找不到似乎可行的解決方案。

+0

嘗試由Bertzzie提供的解決方案http://stackoverflow.com/questions/12022493/could-not-load-type-ajaxcontroltoolkit-sanitizer-antixsssanitizerprovider。 它適用於我。 –

回答

0

我不知道這是否會是你的問題,但我遇到了這個時候,我沒有在System.Web程序在我的web.config以下部分:

<sanitizer defaultProvider="AntiXssSanitizerProvider"> 
     <providers> 
      <add name="AntiXssSanitizerProvider" type="AjaxControlToolkit.Sanitizer.AntiXssSanitizerProvider"></add> 
     </providers> 
    </sanitizer> 

您還需要有這個在您的configsections:

<sectionGroup name="system.web"> 
     <section name="sanitizer" requirePermission="false" 
       type="AjaxControlToolkit.Sanitizer.ProviderSanitizerSection, AjaxControlToolkit" /> 
    </sectionGroup> 
1
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %> 

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit.HTMLEditor" TagPrefix="cc1" %> 

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
    <title></title> 
</head> 
<body> 
    <form id="form1" runat="server"> 
    <div> 
     <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"> 
     </asp:ToolkitScriptManager> 
     <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>  
     <asp:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="TextBox1"> 
     </asp:CalendarExtender> 
     <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> 
     <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox> 
     <cc1:Editor ID="Editor1" runat="server" /> 
     <asp:HtmlEditorExtender ID="HtmlEditorExtender1" runat="server" TargetControlID="TextBox2"> 
     </asp:HtmlEditorExtender> 
     <asp:AnimationExtender ID="AnimationExtender1" runat="server" TargetControlID="TextBox3" > 
     </asp:AnimationExtender> 
    </div> 
    </form> 
</body> 
</html> 

試試這個代碼,不要使在web.config文件中的任何改變我 得到相同的異常早,但是當我嘗試這一點,得到了 解決

0

您必須添加這些行到你的web.config

Configsectons:

<configSections> 
    <sectionGroup name="system.web"> 
     <section name="sanitizer" requirePermission="false" type="AjaxControlToolkit.Sanitizer.ProviderSanitizerSection, AjaxControlToolkit" /> 
    </sectionGroup> 
</configSections> 

的System.Web

<system.web> 
    <sanitizer defaultProvider="AntiXssSanitizerProvider"> 
    <providers> 
     <add name="AntiXssSanitizerProvider" type="AjaxControlToolkit.Sanitizer.HtmlAgilityPackSanitizerProvider" /> 
    </providers> 
    </sanitizer> 

你的麻煩應該消失,就像他們爲我做的那樣。 如果有任何幫助,我會通過在對象瀏覽器中查找找到解決方案。

相關問題