Dynamically adding UserControl "An entry with the same key already exists."

I'm adding a UserControl to a Web Form several times using LoadControl inside the OnInit method.  I get the error "An entry with the same key already exists."  I assume that this is because IDs of the controls inside the second UserControl are conflicting with the first UserControl's childrens' IDs.

The problem is not with the IDs of the UserControls themselves, I ensure that those are unique. 

What kind of a workaround is available?
 

0
luisldq
9/6/2007 5:17:08 PM
asp.net.web-forms 93655 articles. 6 followers. Follow

1 Replies
512 Views

Similar Articles

[PageSpeed] 40

when you create the control, before you add it to the controls collection try setting its ID such as myControl.ID = "somethingunique";  this should keep them separate for you 


Remember if you have gotten your answer to mark your thread as answered.
0
jbardrof
9/6/2007 6:59:38 PM
Reply:

Similar Artilces:

Item has already been added. Key in dictionary: "4" Key being added: "4"
I am getting this error "Item has already been added. Key in dictionary: "4" Key being added: "4" All the other site on the server are working fine excep one which is giving obove error. I didnt made any updates still. show us the code you're using and show us the area where this error is being delivered.David WierMCP/ASPInsiderASPNet101.com - where to look first!Please Vote for ASPNet101 - 'Best Community Resource'!Control Grouper - easily control properties for multiple controls with one control!Calendar Express - The Best HTML Calendar Generator on the web!(Please 'Mark as A...

Item has already been added. Key in dictionary: "Literal1" Key being added: "Literal1"
I intermittently get the error above. I seems to appear when I have made alterations to the GUI of a Custom Module. Does anbody know what causes this to happen?RegardsAndre Colbiornsen ---------------------------------Seventh DayRåbygatan 1A,SE-223 61 LundSwedenMob.: +46-(0)708-97 78 79Mail: info@seventhday.se-------------------------------- Can you put this in a code context. What line is it happening on? Please provide the source surrounding where this error happens. There are a couple of reasons why this may be happening and code may help find the problem. CheersTom Lucas Neve...

General Exception Item has already been added. Key in dictionary: "monday" Key being added: "monday"
I just noticed I have 1000's of these in my log...AssemblyVersion: -1Method: FileName: FileLineNumber: -1FileColumnNumber: -1PortalID: -1PortalName: UserID: -1UserName: ActiveTabID: -1ActiveTabName: AbsoluteURL: AbsoluteURLReferrer: ExceptionGUID: DefaultDataProvider: InnerException: Item has already been added. Key in dictionary: "monday" Key being added: "monday"Message: System.ArgumentException: Item has already been added. Key in dictionary: "monday" Key being added: "monday" at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add) at System.Collections....

Upgrade Error: Item has already been added. Key in dictionary: "www.myhairnet.com" Key being added: "www.myhairnet.com"
I recieved the following error when I upgraded my remote server's test environment from 2.1.2 to 3.0.12: ********************* DotNetNuke Upgrade Error The Assembly Version ( [ASSEMBLYVERSION] ) does not match the Database Version ( [DATABASEVERSION] ) ERROR: Could not connect to database. Item has already been added. Key in dictionary: "www.myhairnet.com" Key being added: "www.myhairnet.com" ******************** I copied the DNN 3.0.12 zip to the server and unzipped it to over the existing test environment after carefully renaming the 2.1.2 web.con...

"Dynamic" Web Services, "Dynamic" Parameters
This is a follow-up discussion from http://forums.asp.net/t/1332722.aspx?PageIndex=2. I noticed we stopped talking about Peter's problem some time ago. The discussion had become one of passing "XML strings" to a web service in order to permit optional parameters, a dynamic web service, and things like that. My contention is that this is a solution without a requirement. It is something that we can do, which does not imply that anyone needs us to do it. First of all, if you need to send XML, then send XML. Do not send a string that happens to have XML embedded in it. ASM...

ScriptManager throws "An entry with the same key already exists."
I have a problem where the ScriptManager is intermittently throwing the following exception.  The interesting thing is that it only seems to occur on our story pages (where a ModalPopupExtender from the Ajax Control Toolkit is used) and only when being hit by our Google Search appliance.If this is a browser capabilities kind of problem, the user agent used by our search appliance (for reference) is: "gsa-crawler (Enterprise; GIX-03476; cctvi@cctvi.com)"Type: System.ArgumentExceptionSource: SystemMessage: An entry with the same key already exists.Stack Trace: at System.Collections.Spe...

PageMethod Exception: "An entry with the same key already exists."
I  am calling a PageMethod from a javascript function. This function is called from many different controls on a page. The problem occurs about the second time the method is called. An exception is thrown saying that an entry with the same key already exists. The weird thing is that everything continues to work normally from the users perspective. I would never have noticed this behaviour if I hadn't be debugging. Its more annoying than developement breaking, but I would still like a solution to it. Except I have no idea how to proceed. Am I just using PageMethod improperly? I'm...

"An entry with the same key already exists"
I've developed a custom Web control that inherits GridView and applies complex formatting logic per cell.  This cell formatting logic is applied per row after the data is bound in the RowDataBound event on GridView.  We've recently found a major issue when multiple requests arrive at the web server at the same time.  For a particular cell, when setting the CssClass of that cell we get the above exception.  The beginning of the stack trace is:<Errors><Error1><ExceptionType>ArgumentException</ExceptionType><StackTrace>   at Sy...

Container control render error "An entry with the same key already exists."
I've created a custom control that inherits from Panel, IPostBackDataHandler.I'm getting a  :An entry with the same key already exists. error with validator controls. I'm guessing because the validator controls are register some javascript functions on their own and during my render override function. Is there a work-around? I also have the same issue with ajax/anthem controls.  ...

Dynamic Web Part Loading Error: "path" argument cannot be empty if the "type" argument is UserControl
I would like to dynamically load web parts, but without using LoadControl*. However, when I try to use the following code, a runtime error is thrown whose meaning is mostly meaningless to me. Control ctrl = (Control)new MyUserControl(); // Control ctrl = LoadControl( "MyUserControl.ascx" ); ctrl.ID = "DynamicUserControl"; GenericWebPart myWebPart = MyWebPartManager.CreateWebPart(ctrl); MyWebPartManager.AddWebPart( myWebPart, MyWebPartManager.Zones[1], 0 );   The error is thrown on the last line, during AddWebPart:   Additional information: The "path" argument cannot be e...

problem with a web project I added as an "existing web site"
I've got a nettiers (DAL) solution that has 5 sub projects in it.  Each with their own dependencies. I copied a web site project into the root of the tree, then said "Add Existing Web Project".  Somehow, when I rebuild, that project gets skipped.  My question is how can I make my web project a first class project in the solution so that when I say "refernece other project" the dependencies automatically work (that is, move dll's into the bin of this web project) and of course I want that project to rebuild right along with the rest. Thanks!  Peter Kellnerhttp://73rds...

Are there different between ViewState.Add("key","Word"); and ViewState["key"] = "Word";
I think the 1 and 2 are complete same, is it correct? 1. ViewState.Add("key","Word"); 2. ViewState["key"] = "Word";SuperCool Multiple ZIP - A utility to unzip multiple files and work with multiple zip filesSuperCool Random Number Generator You are correct, option 2 is short hand for option 1.Philip Beadle (MVP, MCAD, MCT DotNetNuke Core Team)...

<key id="key_savePage" key="&savePageCmd.command.key;" command-"Broswer:SavePage" modifiers="accel"/> ----^
Name: yel0sub Email: yel0subatcomcastdotnet Product: SeaMonkey Summary: <key id="key_savePage" key="&savePageCmd.command.key;" command-"Broswer:SavePage" modifiers="accel"/> ----^ Comments: Downloaded SeaMonkey 1.1.5 with same result on installation. PowerBook G4 OS X 10.4.10 Browser Details: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.1.6) Gecko/20070802 SeaMonkey/1.1.4 ...

Is "Session" the best solution for transfering variables between "Web Forms"??
Hi all; I am using an ASP.NET Web Application (with VB.NET)... and this App used to manage customers' requests.. so, ther user will handel customer#1 data for a while, then he (the user) will handle the data of customer#2. and so on.. And I need to transfer some variables value from one page (Web Form) to onother pages (Web Forms), Is the "Session" variable the BEST solution? and do you recommend me to increase its live to 60 mins or more. (In case the user need approx. 1 hour to handle customer#1 data!!)?? Example of values I want to transfer: CustomerID, RequestNo, Co...

Web resources about - Dynamically adding UserControl "An entry with the same key already exists." - asp.net.web-forms

Placebase team at Apple file “Schematic Maps” patent dynamically detailing important data
In a report from Computerworld way back in 2009, we learned that Apple had quietly acquired Maps API company Placebase. Then, founder of Placebase ...

Apple's Lightning port dynamically assigns pins to allow for reversible use
... a closer look at how Apple's new Lightning connector works, and has come to the conclusion that the 8 pins on each side of the plug are dynamically ...

In a dynamically typed language, is it a bad idea to return different data types?
In some cases, returning different types from a single function works.

Urlbox Launches Screenshots-as-a-Service Platform to Dynamically Update Galleries
... changes. Launched yesterday, Urlbox allows anyone with a gallery displaying website screenshots to automate the process and keep them dynamically ...

Everything.me launcher dynamically adapts to what you’re doing right now
... phone according to what you’re doing. Perform a search for ‘football’ and your background will change to the NFL logo. A launcher that dynamically ...


A YouTube Experiment Resizes the Player Dynamically
There's a new YouTube experiment that changes the video player's size, depending on the browser window's size. When resizing Chrome's window, ...

Apple Granted “Dynamically Changing Cursor for User Interface” Patent, Originally Filed in 2003
... a utility patent that covers the use of the mouse cursor that changes according to the context of the task it is engaged in. Called a “Dynamically ...

Atmel's FPSLIC II Dynamically Reconfigurable SoC Supports "Silicon-Sharing" For Peripherals & Interfaces ...
Silicon-Sharing Fits 200K Gate Design into 40K Gate FPSLIC II's, Cuts Power Drain by 97%

Everything.me Launcher Wants to Dynamically Change Phones Based on Location, Interests, and Mental State ...
What if your phone’s launcher dynamically changed based upon interests, your location, or topics you had in mind at a specific moment? A new ...

Resources last updated: 12/17/2015 8:07:16 PM