The ASP.Net PlaceHolder control provides the functionality to reserve a location on ASP.Net web page that can be further used for adding child controls dynamically. You can change the control hierarchy of web page using this amazing PlaceHolder control that enables you to add and render the ASP.Net server controls dynamically at the runtime. The ASP.Net PlaceHolder control does appear as a physical element on the web page when it loads. Instead it holds a particular location on the page that expands to adjust the new child control added dynamically into it. You can add a single or multiple controls as a collection of controls to the PlaceHolder control. The Controls collection property of PlaceHolder control provides access to the methods such as Add, AddAt, Remove, RemoveAt, Clear etc. These methods allow you to add or remove the controls dynamically.
Sample Code for ASP.Net PlaceHolder Control
asp:PlaceHolder
If you will add the above HTML markup code of PlaceHolder control in the web page it will not display any output control in the browser window. Even if you will try to view the page source code, there will be no HTML element associated to it. The ASP.Net Panel control that we discussed in the previous tutorial also provides the functionality to add the server controls dynamically. You can also customize the appearance of Panel control using CSS styles that renders as HTML div element whereas PlaceHolder control does not renders with visible boundaries or HTML element.
0 comments:
Post a Comment