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 Div control is used to specify a container that groups content into logical sections on Web page. The Div control also enables you to apply CSS (cascading style sheet) rules to content of the control.
The Panel control is used as a container for other controls. This control is often used to generate controls by code and to display or hide groups of controls as per the condition. The Panel control is used as a container for other controls.
Advertisements. The Panel control works as a container for other controls on the page. It controls the appearance and visibility of the controls it contains. It also allows generating controls programmatically. The basic syntax of panel control is as follows: <asp:Panel ID= "Panel1" runat = "server"> </asp:Panel>
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With