title: Getting form field names on Submit when form is user control
body: <p>I am slowly, piece by piece learning what I am doing with ASP.NET</p>
  
  <p>I've created the beginnings of my new web application, but I am often coming up against the issue that ASP.NET renames elements IDs or in the case of form fields, their names.</p>
  
  <p>I have a form which is basically a sales system. It is essentially made up of two User Controls, one is a form for Customer Details (name, address etc) and the second is a form for the customer's purchases, it consists of a number lines dynamically created by Javascript created as you list the items the customer is purchasing. </p>
  
  <p>Both these sections are User Controls because they are to be used for other areas of the system where this data will need to be recalled/re-entered.</p>
  
  <p>When the USer Control is loaded, the field which contains the Customers' Name is renamed <code>"m$mainContent$customerForm$name"</code> I understand where this comes from, "m" is the ID of my Master Page, "mainContent" is the main Content Placeholder and "customerForm" is the name of the User Control.</p>
  
  <p>In fact, in my case, this will always remain the same on all forms, so it is relative easy to overcome... but... suppose it wasn't</p>
  
  <p>I can see there are ways I could deal with this with Javascript, but the form doesn't need an AJAX submit, a normal Post will do fine for this, so when I open up the recieving page I want to call <code>Request.Form("name")%</code> to save the customer's name into the database, but of course I really need <code>Request.Form("m$mainContent$customerForm$name")%</code></p>
  
  <p>How would I dynamically extract those prefixes from the posting form to ensure that if I rename anything or use it in a different scenario, the problem will not break it?</p>
  
  <p>I am using .NET 2.0, so can't use Static Client.</p>