ASP.NET: How To Hide Table Rows In An HTML Table
While I am absolutely an advocate of table-less design, tables are still useful when used correctly. For instance, it is correct to use a table to display tabular data, or to show a form. I came across this extremely simple, but not well-known way to show and hide HTML table rows via the server. Say you have a table:
<table>
<tr>
<td>Hello, World!</td>
<tr>
<tr>
<td>Goodbye, World!</td>
<tr>
</table>
If you want to be able to control your rows on the backend, simply make your <tr> a server tag! I know this seems simple, but at first to me, it appeared counter-intuitive. To do this, change your <tr> to read: <tr id="yourID" runat="server">. Then in your CodeFile you can access its properties, such as yourID.Visible!
Very simple, but hey, the best tricks are.
RSS Feed