Search code examples
asp.netsecurityviewstatedynamic-controls

Secure to store an ID in an ASP.NET control ID?


I'm auto-generating a form in my ASP.NET page. This is already tested and working. I want to know if:

  1. If there are any security problems with storing the database ID as part of my controls ID? I can see think of 2 issues: the id will be visible in page source (not really important in this case), and the possibility someone could change the name of the control somehow? This second possibility is more serious. Is this a potential problem and how to void it?

  2. If there would be a better preferred way to associate a unique data with any type of control? Is it possible to store a custom item in the viewstate for the control?


Solution

  • You can create your own custom controls, inheriting from TextBox, for example. Create properties that store data in the ViewState. That is the fastest and simplest way for me to achieve the result you're needing.