I want to know what is difference between Panel control in asp.net and div with runat="server"? Since both render in div.And i want to know which one is best (conditions)?
Panel and <div>
are the same thing in HTML. The difference is that a
Panel is a web control, and it makes it easier to access the control's
method and properties in the code-behind. Making a <div>
runat server
also allows you to access the properties in the code-behind, but not
as much compare to a Panel web control.
A Panel control requires more processing to generate HTML, while a
<div>
requires less. Which one should you use depends how much of the
properties do you need to access in the code-behind. In general, I
like to stick with plain HTML or HTML controls because they require
less processing on the server, and makes the page load smaller because
they don't use the viewstate.
I think this one was answered here http://stackoverflow.com/questions/877227/asp-net-difference-between-runatserver-and-server-controls
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.