ASP.NET: HtmlGenericControl ("div") or panel

Is there a difference in overhead between using a Panel or HtmlContainerControl if you need to create a serveride container in ASP.NET.

 HtmlContainerControl Container = new HtmlGenericControl("div"); 

Or

 Panel Container = new Panel(); 

Also, are there differences in how they are displayed in different browsers? I noticed that Panel looks like a div in all browsers that I used.

+6
html c # panel
source share
1 answer

Panel supports additional functions such as Direction, BackImageUrl, ScrollBars, etc. However, if all you need is a div, I will use HtmlGenericControl .

It is explicit, which makes the code easier to read . It also gives you more control over markup, for example. you may not agree with how Microsoft launched something like BackImageUrl.

+6
source share

All Articles