-
Notifications
You must be signed in to change notification settings - Fork 1
JavaScript
It seems every year or so, Microsoft decides to arbitrarily change their naming conventions for server-side controls as generated on the client-side. It used to be parentControl_childControl
, and then it turned into something crazy with dollar signs and numbers, breaking any client-side code you may have used to reference controls by fully-qualified ID.
Although you can force your site to use a certain method via configuration settings, I recommend future-proofing your jQuery selectors.
Per Encosia benchmarks, for a server-side TextBox control, the recommended method is
$('input[id$=txtInput]');
Obviously you need to be aware of which HTML object each control translates to (e.g. LinkButton = <a/>
, Button = <input/>
, DropDownList = <select/>
, Multiline Textbox = <textarea/>
).
Pages in this wiki make use of the following resources throughout
- Martin, R. C., Feathers, M. C., Ottinger, T. R., Langr, J. J., Schuchert, B. L., Grenning, J. W., Wampler, K. D., ... Coplien, J. O. (2011). Clean code: A handbook of agile software craftsmanship. Upper Saddle River [etc.: Prentice Hall.
- Lowy, Juval, (July 2011). “C# Coding Standard: Guidelines and Best Practices.” (Version 2.4) www.idesign.net, © 2011 IDesign Inc.
Resources besides these will be referenced directly where they are cited.