I'm serving up a page using ASP.Net. I have Add/Edit/Delete functionality of controls I've added dynamically using jQuery on a page, some of which have related records in a database. Where is the best place to put the id (primary key) for these, an attribute, data-*, jQuery.data()? Should I be concerned if the Id is visible client-side?
It's good practice to encrypt the ID of the record on the client side to ensure the security of your database. Usually a hidden field will do the trick.
This way, the user only sees the encrypted id upon viewing the source. The script being called then uses the key used to encrypt to retrieve the record identifier server side and manipulate data as needed.
Firstly do not use the direct database ID. You will be tied to directly to one version of one table's Primary Key. Instead create a second column, using UUID to be the place holder of primary key
for example
tbl_person
person_id INT PRIMARY KEY
person_uuid VARCHAR(64)
name VARCHAR(128)
But to answer the actual question, I suggest you use an attribute of the appropriate element, proabbly id
<tr><td id="1234-5678">Paul </td></tr>
(edit to get code formatting right)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With