You place a control onto your page:
<asp:Content ID="Content1" ContentPlaceHolderID="Content" Runat="Server"> <asp:TextBox Id="Firstname" Runat="Server" /> </asp:Content>
The output is rendered as:
<input name="ctl00$Content$FirstName" type="text" id="ctl00_Content_FirstName" />
In the example above, the disparity in the rendered id attribute occurs because the TextBox control has been placed within a Content control, as the Page object inherits a MasterPage.
var $firstname = $("[id$=FirstName]");
This little snippet makes use of the jQuery attributeEndsWith selector, as documented here.Â Bare in mind that an array is returned, as any control with an id that ends in FirstName will be selected.