System.ArgumentException:具有相同键的条目已经存在 [英] System.ArgumentException: An entry with the same key already exists

查看:2149
本文介绍了System.ArgumentException:具有相同键的条目已经存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的母版,我用acordion菜单

 <%@主语言=C#AutoEventWireup =真
            codeBehind =DefaultMaster.Master.cs继承=Lab.DefaultMaster的ClientIDMode =静态%GT;<%@导入命名空间=资源%GT;!< D​​OCTYPE HTML PUBLIC - // W3C // DTD XHTML 1.0过渡// EN
                     http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">< HTML的xmlns =htt​​p://www.w3.org/1999/xhtml>
<头=服务器>
<链接类型=文/ CSS的href =CSS / style.css文件的rel =stylesheet属性/>
<标题>
< ASP:的ContentPlaceHolder ID =标题=服务器>
< / ASP:&的ContentPlaceHolder GT;
< /标题>
<链接HREF =CSS /自定义主题/ jQuery的-UI-1.8.2.custom.css类型=文/ CSS
 相对=样式/>
<链接类型=文/ CSS的href =CSS / accordion.css的rel =stylesheet属性/>
<脚本类型=文/ JavaScript的SRC =/ JS / jQuery的-1.4.2.min.js>< / SCRIPT>
<脚本类型=文/ JavaScript的SRC =/ JS / jQuery的-UI-1.8.2.custom.min.js>< / SCRIPT>
<脚本的src =/ JS / jquery.cookie.js类型=文/ JavaScript的>< / SCRIPT>
<脚本类型=文/ JavaScript的SRC =/ JS / ddaccordion.js>< / SCRIPT>
<脚本类型=文/ JavaScript的>
ddaccordion.init({//顶层头初始化
headerclass:可扩展,//共享CSS类的头组的名称是
扩展
内容类:内容组的categoryitems,//共享的CSS类名
revealtype:点击,//显示内容时,用户点击或的onmouseover头?
有效值:点击,单击搜索或鼠标悬停
mouseoverdelay:以毫秒为单位200,//如果revealtype =鼠标悬停,设置延时
 前头扩展的onmouseover
崩溃preV:真,//收起previous内容(所以只有一个随时打开)?
真假
defaultexpanded:[0],//内容(s)的默认的[索引1,索引2等]打开的索引。
 []表示没有内容
onemustopen:假的,//指定至少一个头是否应该公开始终(所以
从来没有全部关闭头)
animatedefault:假的,//应该默认打开的内容是动画眼帘?
persiststate:真,//浏览器会话中坚持的打开状态的内容?
toggleclass:[,openheader],//两个CSS类被应用到的标题时
它的折叠和展开,分别为[1级,类别2]
togglehtml:[preFIX,,],//附加的HTML加到首部时,它的
分别折叠和展开,[位置,HTML1,HTML2(见文档)
animatespeed:动画的快,//速度:以毫秒为单位的整数(即:200)
或关键字快,正常,或慢
OnInit的:功能(头,expandedindices){//定制code运行时头
  已经initalized
//没做什么
},
onopenclose:功能(标题,索引和状态,isuseractivated){//定制code到
运行时的报头被打开或关闭
//没做什么
}
});
ddaccordion.init({//二级头初始化
headerclass:subexpandable,//子头组共享的CSS类名
是可扩展
内容类:子内容组的subcategoryitems,//共享的CSS类名
revealtype:点击,//显示内容时,用户点击或的onmouseover头?
有效值:单击或鼠标悬停
mouseoverdelay:200,//如果revealtype =鼠标悬停,以毫秒为单位前设置延时
 头扩展的onmouseover
崩溃preV:真,//收起previous内容(所以只有一个随时打开)?
 真假
defaultexpanded:[],//内容(s)的默认的[索引1,索引2等]打开的索引。 []
 表示没有内容
onemustopen:假的,//指定至少一个头是否应该公开始终(所以
 从来没有全部关闭头)
animatedefault:假的,//应该默认打开的内容是动画眼帘?
persiststate:真,//浏览器会话中坚持的打开状态的内容?
toggleclass:[opensubheader,closedsubheader],//要施加两个CSS类
 当它崩溃了头和扩大,分别为[1级,类别2]
togglehtml:[无,,],//附加的HTML加到首部时,它的
 分别折叠和展开,[位置,HTML1,HTML2(见文档)
animatespeed:动画的快,//速度:以毫秒为单位的整数(即:200)
 或关键字快,正常,或慢
OnInit的:功能(头,expandedindices){//定制code运行时头
  已经initalized
//没做什么
},
onopenclose:功能(标题,索引和状态,isuseractivated){//定制code
运行时的报头被打开或关闭
//没做什么
}
});
< / SCRIPT>< ASP:的ContentPlaceHolder ID =头=服务器>< / ASP:&的ContentPlaceHolder GT;<风格类型=文/ CSS>
.style1
{
宽度:140px;
}
< /风格>< /头>

//身体

 <车身风格=最小宽度:930px;>
<表格边框=0的cellpadding =5CELLSPACING =0WIDTH =100%>
&所述; TR>
< TD风格=垂直对齐:首位;类=STYLE1>
< D​​IV CLASS =arrowlistmenu>< H3类=menuheader扩展> ASD< / H3 GT&;
< UL类=categoryitems>
<立GT;< A HREF =/ GeneralData / Data.aspx> ASD< / A>< /李>
< / UL>< H3类=menuheader扩展> SD< / H3 GT&;< UL类=categoryitems><立GT;< A HREF =/指示/ page2.aspx> SDF< / A>< /李>
<立GT;< A HREF =/指示/ page3.aspx> SDF< / A>< /李>
<立GT;< A HREF =#> SDF< / A>< /李>
<立GT;< A HREF =#> SDF< / A>< /李>
<立GT;< A HREF =#> SDF< / A>< /李>
<立GT;< A HREF =#> SDF< / A>< /李>< / UL>< H3类=menuheader扩展> SDF< / H3 GT&;
< UL类=categoryitems>
<立GT;< A HREF =#> SDF< / A>< /李>
<立GT;< A HREF =#> ASD< / A>< /李>
<立GT;< A HREF =#> ASD< / A>< /李>
< / UL>
< H3类=menuheader扩展> ASD< / H3 GT&;
< / DIV>< / TD>< / TR>< /表>
< /身体GT;
< / HTML>

启动一个页面的时候,他给我的错误

 在'/'应用程序的服务器错误。具有相同键的条目已经存在。说明:执行当前Web的执行过程中发生未处理的异常
请求。请检查堆栈跟踪有关该错误以及更多信息
它起源于code。异常详细信息:System.ArgumentException:具有相同键的条目已经存在。源错误:
当前Web请求的执行过程中生成了未处理的异常。

有关异常的来源和位置的信息可以被识别
    使用异常堆栈跟踪下面。

 堆栈跟踪:
[ArgumentException的:具有相同键已经存在的条目。]
   System.Collections.Specialized.ListDictionary.Add(对象键,对象的值)
                                                                           6236205
   System.Web.UI.ClientScriptManager.RegisterExpandoAttribute(字符串控件ID,
  字符串的attributeName,字符串的AttributeValue,
 布尔带code)272
   System.Web.UI.ScriptRegistrationManager.RegisterExpandoAttribute(控制控制,
 字符串控件ID,字符串的attributeName,
字符串的AttributeValue,布尔带code)+115
   System.Web.UI.ScriptManager.RegisterExpandoAttribute(控制控制,S
   特林控件ID,字符串的attributeName,
 字符串的AttributeValue,布尔带code)+44


解决方案

你是一个幸运,有一个错误的原因在code的第一个行。因为我只是被它吓坏了。更改验证器的的ClientIDMode predictable

My masterPage, I use acordion menu

<%@ Master Language="C#" AutoEventWireup="true" 
            CodeBehind="DefaultMaster.Master.cs" Inherits="Lab.DefaultMaster" 

ClientIDMode="Static" %>

<%@ Import Namespace="Resources" %>

<!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">
<link type="text/css" href="css/style.css" rel="Stylesheet" />
<title>
<asp:ContentPlaceHolder ID="title" runat="server">
</asp:ContentPlaceHolder>
</title>
<link href="css/custom-theme/jquery-ui-1.8.2.custom.css" type="text/css" 
 rel="Stylesheet" />
<link type="text/css" href="css/accordion.css" rel="Stylesheet" />
<script type="text/javascript" src="/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="/js/jquery-ui-1.8.2.custom.min.js"></script>
<script src="/js/jquery.cookie.js" type="text/javascript"></script>
<script type="text/javascript" src="/js/ddaccordion.js"></script>
<script type="text/javascript">


ddaccordion.init({ //top level headers initialization
headerclass: "expandable", //Shared CSS class name of headers group that are 
expandable
contentclass: "categoryitems", //Shared CSS class name of contents group
revealtype: "click", //Reveal content when user clicks or onmouseover the header?
Valid value: "click", "clickgo", or "mouseover"
mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds 
 before header expands onMouseover
collapseprev: true, //Collapse previous content (so only one open at any time)? 
true/false 
defaultexpanded: [0], //index of content(s) open by default [index1, index2, etc]. 
 [] denotes no content
onemustopen: false, //Specify whether at least one header should be open always (so  
never all headers closed)
animatedefault: false, //Should contents open by default be animated into view?
persiststate: true, //persist state of opened contents within browser session?
toggleclass: ["", "openheader"], //Two CSS classes to be applied to the header when 
it's collapsed and expanded,

respectively ["class1", "class2"]
togglehtml: ["prefix", "", ""], //Additional HTML added to the header when it's 
collapsed and expanded, respectively

["position", "html1", "html2"] (see docs)
animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), 
or keywords "fast", "normal", or "slow"
oninit: function (headers, expandedindices) { //custom code to run when headers
  have initalized
//do nothing
},
onopenclose: function (header, index, state, isuseractivated) { //custom code to 
run whenever a header is opened or closed
//do nothing
}
});
ddaccordion.init({ //2nd level headers initialization
headerclass: "subexpandable", //Shared CSS class name of sub headers group that
are expandable
contentclass: "subcategoryitems", //Shared CSS class name of sub contents group
revealtype: "click", //Reveal content when user clicks or onmouseover the header? 
Valid value: "click" or "mouseover
mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before 
 header expands onMouseover
collapseprev: true, //Collapse previous content (so only one open at any time)? 
 true/false 
defaultexpanded: [], //index of content(s) open by default [index1, index2, etc]. [] 
 denotes no content
onemustopen: false, //Specify whether at least one header should be open always (so 
 never all headers closed)
animatedefault: false, //Should contents open by default be animated into view?
persiststate: true, //persist state of opened contents within browser session?
toggleclass: ["opensubheader", "closedsubheader"], //Two CSS classes to be applied 
 to the header when it's collapsed

and expanded, respectively ["class1", "class2"]
togglehtml: ["none", "", ""], //Additional HTML added to the header when it's 
 collapsed and expanded, respectively

["position", "html1", "html2"] (see docs)
animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200),
 or keywords "fast", "normal", or "slow"
oninit: function (headers, expandedindices) { //custom code to run when headers
  have initalized
//do nothing
},
onopenclose: function (header, index, state, isuseractivated) { //custom code
to run whenever a header is opened or closed
//do nothing
}
});


</script>

<asp:ContentPlaceHolder ID="head" runat="server">

</asp:ContentPlaceHolder>

<style type="text/css">
.style1
{
width: 140px;
}
</style>

</head>

//body

<body style="min-width:930px;">
<table border="0" cellpadding="5" cellspacing="0" width="100%">
<tr>
<td style="vertical-align:top;" class="style1">
<div class="arrowlistmenu">

<h3 class="menuheader expandable">asd</h3>
<ul class="categoryitems">
<li><a href="/GeneralData/Data.aspx">asd</a></li>
</ul>

<h3 class="menuheader expandable">sd</h3>

<ul class="categoryitems">

<li><a href="/Instruct/page2.aspx">sdf</a></li>
<li><a href="/Instruct/page3.aspx">sdf</a></li>
<li><a href="#">sdf</a></li>
<li><a href="#">sdf</a></li>
<li><a href="#">sdf</a></li>
<li><a href="#">sdf</a></li>

</ul>

<h3 class="menuheader expandable">sdf</h3>
<ul class="categoryitems">
<li><a href="#">sdf</a></li> 
<li><a href="#">asd</a></li>
<li><a href="#">asd</a></li>
</ul>
<h3 class="menuheader expandable">asd</h3>
</div>

</td></tr></table>
</body>
</html>

when launching a page, he gave me error

Server Error in '/' Application.

An entry with the same key already exists.

Description: An unhandled exception occurred during the execution of the current web 
request. Please review the stack trace for more information about the error and where
it originated in the code. 

Exception Details: System.ArgumentException: An entry with the same key already exists.

Source Error: 


An unhandled exception was generated during the execution of the current web request. 

Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[ArgumentException: An entry with the same key already exists.]
   System.Collections.Specialized.ListDictionary.Add(Object key, Object value)
                                                                           +6236205
   System.Web.UI.ClientScriptManager.RegisterExpandoAttribute(String controlId, 
  String attributeName, String attributeValue,
 Boolean encode) +272
   System.Web.UI.ScriptRegistrationManager.RegisterExpandoAttribute(Control control, 
 String controlId, String attributeName, 
String attributeValue, Boolean encode) +115
   System.Web.UI.ScriptManager.RegisterExpandoAttribute(Control control, S
   tring controlId, String attributeName,
 String attributeValue, Boolean encode) +44

解决方案

You are a lucky to have an error cause in very first rows of your code. Because I'm just horrified by it. Change your validator's ClientIDMode to Predictable.

这篇关于System.ArgumentException:具有相同键的条目已经存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆