简体   繁体   中英

Difference between Panel control and Div

I want to know what is difference between Panel control in asp.net and div with runat="server" ? Since both render as a div .

Which one is best (conditions)?

The code

<asp:Panel id="abc" runat="server">

is exactly the same as if you do:

<div id="abc" runat="server">

They render the same, but it's the functionality with other WebControls that the Panel is most used, and the Panel web control gives you more control under code-behind as it exposes more properties.

The difference is that Panel is a webcontrol which will give you more properties over div in the code behind file, since it's a webcontrol it will require more processing to generate HTML.

The panel control has the viewstate property while div does not.

It really depends on your usage. If you prefer to have control over more properties, then use the panel control, otherwise use the div control.

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