I assume that you can access your tr because the table is running on the server and tr is part of the table itself.
On the other hand, the span is only accessible from the client because it is not displayed on the server side.
if you add id to some td for the table, you can access it also on the server side of the script. However, if you remove runat="server" from the table, you will get build errors when you try to access the components of the table.
<table runat="server"> <tr id="myTr"> <td id="myTd">Hello</td> <%--This td is also accessible from the server script--%> <td><span id="mySpan">World</span></td> </tr> </table>
UPDATE: Well, this is no longer a hunch. According to the great explanation of Michael Amundsen and Paul Lytvyn in their ASP.NET book for developers . You can see the reason.
To summarize according to your comment: On page 136, the subheadings: Table Heading (Th), String (Tr), and Part (Td): "You can also use server-side code to manage the table tr, td, and td tags. Listing 8.9 Manipulating Th, Tr, and Td tags using server code is very similar to yours.
Basically a table with runat="server" and th , tr and td elements with id attributes (without runat = "server"), which are effectively accessed by the Page_Load event handler at the top of the list.
If you continue reading, you will see an explanation of the server controls and how ASP.NET maps them to HTML elements.
Hope this helps!
source share