After having this problem several times and continually forgetting the fix, I figured I'd go ahead and make a post about it. Hopefully, it'll save someone time in the future. Let me know if you have a different fix.
Symptoms
When you browse to a DNN page after adding a new module to the page, you receive an error message that is similar to the following:
Multiple controls with the same ID 'ctr123_DD' were found. FindControl requires that controls have unique IDs.
Cause
DNN dynamically loads modules to the page when it loads and references them using the Control.FindControl() method. As the error specifies, FindControl() can only be used when all IDs are unique. This usually happens when a module definition has been recently modified. DNN modules are identified using a combination of the key and type properties. To specify the control that should be loaded when a user browses to a page with the module, the key should be blank and the type should be "View". The default edit control (i.e. Add content) and the settings controls should have key values of "Edit" and "Settings", respectively. All other controls need to have unique key values. When non-unique key values are used, DNN loads all of the controls with the same ID, which is the true culprit.
Resolution
First, you'll have to know what module is causing the problem. If you are unsure of which module is causing the problem, there are three ways to figure it out:
- If a module was just added to the page before the error occurred, the module that was added is most likely the problem. (Cause you needed me to tell you that, right?)
- If a module on the page that's giving you the error was just added, that module is most likely causing the error. (Another great hint!)
- If neither of the previous identification methods work, the module ID is listed in the error. "ctr123_DD" refers to module 123. Take a look in the
dnn_Modules table and the row with that ModuleId is definitely the problem.
After finding the offending module, browse to the module definitions page (Host > Module Definitions) and check to ensure all module controls have unique key values. Remember: default view is blank, default edit is "Edit", settings is "Settings", and all others can be whatever makes your little heart go pitter-patter. Once the key values are corrected, you will most likely have to restart IIS. The quickest way to do this is to use iisreset (Start > Run, type iisreset, click OK).
More Information
- Applies to: DotNetNuke 1.0 - 3.1 (I don't think it's been fixed in newer releases, yet; but I haven't confirmed anything newer than 3.1)
- There is another error that does not specify the module ID, "Multiple controls with the same ID 'ctr' were found." This fix does not apply to those. If/when I run into that one again, I'll try to post a fix on that, too.
I may have found the cause of the 'ctr' error. It seems that this is caused with malformed HTML within the ASCX and/or mis-matched assembly (I didn't notice there was a build error because VS was saying it built successfully, for some reason.) This happened right after editing a module control, so I just opened the ASCX file in the designer and solved the problem pretty easily. I'm pretty sure this also happened when I wasn't customizing a control, but I can't really remember. That's all I really have right now. Hope it helps someone.