title: How to get the generated Unique ID prefix for a page's controls
body: <p>As we know, ASP.NET WebForms will generate a Unique ID (as well as name) to a control to prevent collisions in the control heirarchy.  Let's say we have a TextBox control with an assigned ID of &quot;MyTextBox&quot; in the markup.  If this textbox is on a page with a Master Page then the TextBox control will be given a Unique ID of &quot;ctl00$MainContent$MyTextBox&quot; or something similar.</p>
  <p>What I want to know is, for a given page, is it possible to know what the prefix WILL BE?  In my above example I would like to know all controls I create on that page will be assigned with a prefix of &quot;ctl00$MainContent$&quot;.  I have examined the Page object and I cannot find an easy way to extract this information.  Note: inspecting already existing controls on the page (like the TextBox) isn't an option.  I simply need to know, at run time, what the prefix would be.</p>
  <p><strong>-- EDIT: Why do I need to do this? --</strong></p>
  <p>Ultimately I am trying to solve the problem that this post illustrates:</p>
  <p><a href="https://stackoverflow.com/questions/24082754/asp-net-4-5-tryupdatemodel-not-picking-form-values-in-webform-using-master-page">ASP.NET 4.5 TryUpdateModel not picking Form values in WebForm using Master-Page</a></p>
  <p>I'm using the ModelBinding features introduced in ASP.NET 4.5.  Problem is, as the above post points out, is that the name value collection found in the form will NOT match up with your model's properties.  The built-in FormValueProvider expects a one-to-one match with the form key (name) and the model's properties. Unfortuantely, the form's keys will have the typical &quot;ctl00$MainContent$&quot; prefix to the names.</p>
  <p>I have a semi-working solution where I created a custom IValueProvider that compares the <em>end of</em> the form key with the model's property.  This works 95% of the time, but there's always a chance of multiple hits.</p>
  <p>Ideally, and this is what I'm trying to figure out, if I could determine WHAT the prefix is I can then prefix that the IValueProvider's passed in key, look for that in the form and find the exact match.</p>
  <p>So that is why I'm wondering if there's any way to know what the prefix should be for a given page.</p>