If you don’t provide an ID for your declared controls in ASPX files, I know that VS will automatically generate one for you. Should I always give the controls a descriptive ID even when I won’t be accessing them from the code-behind?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is more of a preference thing, really. I tend give names to most of my elements, except for things like labels that I’ll never change. I take special care to name all of my div’s, for example, for my own sanity when the time comes to modify a layout later.
I suppose that sums up the reason I do it, then. Giving names for most of your controls is more declarative and easier to read. If you’re concerned about “polluting” your Intellisense, just use a common prefix between similar controls (like TxtFirstName for a textbox).