简体   繁体   中英

ASP.NET: HtmlGenericControl(“div”) or Panel

Is there any difference in overhead between using Panel or HtmlContainerControl when needing to create a serverside container in ASP.NET.

HtmlContainerControl Container = new HtmlGenericControl("div");

Or

Panel Container = new Panel();

Also, are there any differences in how it is rendered in different browsers? I've noticed that Panel seems to render as a div in all browsers I have used.

Panel supports extra functionality such as Direction, BackImageUrl, ScrollBars, etc... However if all you need is a div, I would use HtmlGenericControl .

It is explicit which makes for better code readability . It also gives you more control over the markup, eg you may not agree with how something like BackImageUrl has been implemented by Microsoft.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM