HTMLEditorExtender 导致“Key 不能为 null”错误
我的 ASP.Net C# 项目编译并运行良好,除非我尝试加载带有 Ajax Control Toolkit HTMLEditorExtender 的特定页面。我收到“密钥不能为空页面”错误。我尝试删除 htmleditorextender 并放置一个 asynchfileupload 控件,只是为了确保脚本管理器正常工作,并且页面正常显示并且上传控件正常工作。所以这是专门针对 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
任何帮助将不胜感激。我尝试用谷歌搜索此错误,但找不到似乎有效的解决方案。
My project in ASP.Net C# is compiling and running fine except for when I try to load a specific page which has an Ajax Control Toolkit HTMLEditorExtender on it. I get a Key cannot be null page error. I tried removing the htmleditorextender and putting an asynchfileupload control instead just to make sure the scriptmanager was working, and the page comes up fine and the upload control works. So it is something with the htmleditorextender specifically. Here is the code I have:
<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>
The line that shows the error on the page error is this one:
<cc1:HtmlEditorExtender ID="HTMLEditorExtender" runat="server" TargetControlID="txtMailMsgContent">
This is the stack trace:
[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
Any help would be greatly appreaciated. I've tried googling this error and can't find a solution that seems to work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不知道这是否是您的问题,但是当我在 system.web 的 web.config 中没有以下部分时,我遇到了这个问题:
您还需要在配置部分中包含以下内容:
I don't know if this will be your problem, but I encountered this when I didn't have the following section in my web.config in system.web:
You'll also need to have this in your configsections:
您必须将这些行添加到您的 web.config
Configsectons:
System.web
您的麻烦应该会消失,就像它们为我所做的那样。
如果有任何帮助,我通过查看对象浏览器找到了解决方案。
You have to add these lines to your web.config
Configsectons:
System.web
Your troubles should go away as they did for me.
If its of any help I found the solution by looking in the Object browser.