title: ASP.NET MVC, a plugin architecture and id collisions
body: <p>So I have been waxing lyrical about a ASP.NET MVC to a friend who is about to start development of a new user interface....</p>
  
  <p>He asked me if you could solve the following problem with ASP.NET MVC:</p>
  
  <p><strong>Imagine a web app that supports plugins. In the current ASP.NET WebForms app the pluggin developer provides a usercontrol and some JQuery.
  The IDs of the controls are unique so that the JQuery can always select the correct DOM elements and so that the code behind can deal with the correct control collections.</strong></p>
  
  <p>I suggested that in MVC since we can have any number of forms... each plugin could be implemented as a partialView.</p>
  
  <p>Each partialView would be wrapped by its own form so the relevant Controller Action and therefore would only receive form data defined in the partialView - so from this point of view we dont care about DOM id collisions.</p>
  
  <p>However the HTML would be invalid if ID collision did occur and hence JQuery written by the plugin developer could fail!</p>
  
  <p>I'm not sure how we could get round this...</p>
  
  <p>I dont like the idea of parsing the partialView for collisions when the plugin is added and I dont like the idea of restricting the ids that the plugin developer has access to.</p>
  
  <p>Maybe the the ids could be augmented with a prefix at run time and the model binders could be provided with this prefix? </p>