본문 바로가기
ASP.NET

ASP.NET - PlaceHolder와 Panel의 차이 및 구현

by 개발 그리고 게발 2021. 7. 12.
728x90

PlaceHolder와 Panel은 어떠한 구역에 Visible처리할 때 주로 쓰입니다.

 

PlaceHolder와 Panel태그 내부에 어떤 Html태그를 작성했을 경우 결과로 표시되는 내용에 대해선 별 차이를 느끼지 못할 수 있는데 간단한 차이가 있습니다.

 

 

 


 

 

예시

<asp:PlaceHolder ID="PlaceHolder1" runat="server">
	<span>This is Placeholder server control</span>
</asp:PlaceHolder>

<asp:Panel ID="Panel1" runat="server">
	<span>This is Panel server control</span>
</asp:Panel>

 

Html 결과

<span>This is Placeholder server control</span>

<div>	
	<span>This is Panel server control</span>        
</div>

 

 


 

 

 

 

* PalaceHolder로 묶은 영역은 서버컨트롤으로 인한 추가적인 Html태그가 발생하지 않습니다.

* Panel로 묶은 영역은 div태그가 발생되어 의도치않은 Html태그가 추가될 수 있습니다.

 

Panel태그는 div태그를 발생시키기 때문에 div태그의 css속성(Front, Border, Back-ground Image)이나 class명을 미리 넣어줄 수 있습니다.

 

하지만 현업에서 사용될 때는 Front-end와 Back이 분리되어 있어 css영역은 Front-end에 맡기는 것이 좋습니다.

 

임의로 div태그를 추가해야 하고, css속성 및 클래스를 추가해야 할 일이 발생하지 않는다면 Panel보다는 PlaceHolder를 쓰는 것이 깔끔할 것 같습니다.

728x90

댓글