I’ve made a few master pages in visual studio, and then a few implementing pages, and Visual Studio sticks ID attributes onto all of my tags:
<asp:Content ID="Content1" ContentPlaceHolderID="OtherContent" ></asp:Content>
What gives with the IDs? What are they good for? How do I access them from the code behind?
All controls that run on the server must have an ID attribute as a unique identifier. They are good for finding child controls and keeping the control hierarchy in place. If you have a TextBox that sits in a Panel that sits in an UpdatePanel that’s in a WebUserControl that’s in a ContentPlaceHolder that’s in a Page, then all it takes is one of them not to have a proper ID attribute in order keep the connection between TextBox and Page.
In order to access it from the code behind you need to have the
runat="server"attribute set on this tag.