title: What prevents a user from adding controls to an ASP.NET page client side?
body: <p>This goes back to my other question which I thought was sufficiently answers but upon reflect am not sure that it was (sorry).</p>
  
  <p>Backgrounder:</p>
  
  <ol>
  <li><p>I am generating a form dynamically. I am pulling from the database the controls.</p></li>
  <li><p>I must associate each control with a database ID which is not the user's session id. I do this currently by storing my ID in the ID for the web control with some other stuff to make it unique/clear what I am doing.</p></li>
  <li><p>On the post back, I iterate through all the controls on my web page checking for my special identifier, ie, MyGeneratedTextBox_ID_Unique. This process enables for 2 important steps, identifying the control was one I generated and also getting the ID for this input field.</p></li>
  </ol>
  
  <p>And, all of this works but I'm still concerned about the security of it. I do not see a security issue with showing the actual database ID's in this case, although agree it is not desirable. However, I am concerned of the following possibilities:</p>
  
  <ol>
  <li><p>If a user could add a nefarious control to my collection and use that for a SQL injection attack.</p></li>
  <li><p>More academic, but if a user could somehow store data for fields they do not have access too by changing the id's.</p></li>
  </ol>
  
  <p>I agree this is a "hack" of a way to do it. But my question is, is it a security risk and is there an 'easy' way to do it in a less hack way?</p>
  
  <p>I assume that only the controls that are created/instantiated on the page are added to the controls list.. thus all controls must be created server side and thus the security issue is address but just wanted to validate. Thanks again.</p>
  
  <p>PS:
  I could see adding a property for each control and encrypting the viewstate would be a little more secure.</p>