开发者

<asp:Table> Vs html <table> [closed]

开发者 https://www.devze.com 2022-12-29 05:22 出处:网络
Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by开发者_运
Closed. This question is opinion-based. It is not currently accepting answers.

Want to improve this question? Update the question so it can be answered with facts and citations by开发者_运维知识库 editing this post.

Closed 9 years ago.

Improve this question

What are the differences between the ASP.Net control <asp:Table> 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, but does the ASP.Net control come with any benefits that I'm missing?


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>.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消