ASP.NET:HtmlGenericControl(“div”) 或面板
当需要在 ASP.NET 中创建服务器端容器时,使用 Panel
或 HtmlContainerControl
之间的开销有什么区别吗?
HtmlContainerControl Container = new HtmlGenericControl("div");
或者
Panel Container = new Panel();
另外,它在不同浏览器中的呈现方式是否有任何差异?我注意到 Panel 似乎在我使用过的所有浏览器中呈现为 div。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
面板支持额外功能,例如方向、BackImageUrl、ScrollBars 等...但是,如果您需要的只是一个 div,我会使用 HtmlGenericControl。
它是明确的,这使得更好的代码可读性。它还使您可以更好地控制标记,例如,您可能不同意 Microsoft 实现 BackImageUrl 等内容的方式。
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.