Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 789
cweston Avatar asked Feb 10 '11 22:02

cweston


1 Answers

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, e.g. you may not agree with how something like BackImageUrl has been implemented by Microsoft.

like image 64
Alex Angas Avatar answered Oct 20 '22 16:10

Alex Angas