tags:

views:

112

answers:

3

What are the pros and cons between using the ASP.Net control compared to the old reliable table html implementation.

I know that the asp:Table will end up on the returned page as a html table, and from looking into it so far people are saying its easier to work with the asp:Table in the server side code, but I'd love to hear what the stackoverflow community has to say about the matter.

+2  A: 

A "regular" <table> is not available for modification at all on the server side. As far as the server-side is concerned, it's just static text that gets output to the browser.

I would say that as a general rule, favour <table> unless you explicitly need to modify the structure of the table on the server. Using <asp:Table> means you have the overhead of running the code-behind for the table, generating the server-side control and so on. If you're not using any of that functionality, then there's no point.

Also, in general, <asp:DataTable> is typically more useful than just plain <asp:Table>, since it supports data-binding and so on.

Usually, if I just want to show/hide a single row in a table (or something) then I'll just put runat="server" on the single <tr> that I want to control, rather than using a whole <asp:Table>.

Dean Harding
+1  A: 

You can always give a regular table an ID and put a runat="server" tag on it and access it as well if needed...

davidsleeps
A: 

Be aware that there are cases in which ASP HtmlTables cannot output standards-compliant HTML. For instance, they do not support complete table semantics (thead/tfoot/tbody, cols, caption...); they'll throw an exception if you try to include those elements programmatically.

These are serious limitations for accessible content.

Superstringcheese