Introduction
Hi all, next time you create dynamic controls in your web page, don't think about using placeholder control.I thought of it using as a container to store dynamically added server controls in my Web page.
Only during runtime, you can add controls to it. I tried to position the placeholder and also tried to position the child control. Alas, nothing happening with it.
You can use the PlaceholderControl.Controls collection to add, insert, or remove a control from the PlaceHolder control. Ok. Why would one wants to remove the control dynamically?
HtmlButton myButton = new HtmlButton();
myButton.InnerText = "Button 1"; myButton.Style.Add("Width", "100"); myButton.Style.Add("Left", "200"); myButton.Style.Add("Top", "100"); PlaceHolder1.Controls.Add(myButton);
I could set the "width" of the button;but not the "left" and "Top" attributes. They are simply not working.
Once you set placeholder's visible property to false, it does not produce any visible output, but still, can be used as a container for other controls. I just don't find any reason to add controls in the background without seeing them on my page. Do my web page have to include a long running calculations and manipulations with this kind of hidden controls?
It reserves a location in the page control hierarchy for dynamic controls that are added programmatically. If its not reserving a location in the page layout, what is the use?
During design time, I had a hell of time on why you choose place holder control. You cannot add controls to the placeholder during runtime.
Compared to Panel control, placeholder control provides nothing. No backcolor, forecolor, border settings and font settings!
I was really disappointed on using a placeholder in my application. No proper documentation is found for this control.
Summary
I simply don't know why the placeholder control is added, by default, in the tool box. Could anyone of you, or from Microsoft help me?
|
| Author: Mike Cunningham 15 Jun 2005 | Member Level: Bronze Points : 0 |
I was able to get the PlaceHolder control to work ONLY after I placed it inside a Panel/Div control.
Does that make sense... NOT ONE BIT... :)
|
| Author: sb 28 Oct 2005 | Member Level: Bronze Points : 0 |
You bet... this thing totally sucks! I struggled with it for so long... I put it inside panel and it worked! Thanks so much for the tip. sb
|