C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » .NET Framework »

Nightmare on PlaceHolder Control


Posted Date: 10 Jun 2005    Resource Type: Articles    Category: .NET Framework
Author: Balamurali BalajiMember Level: Diamond    
Rating: 1 out of 5Points: 10



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?




Responses

Author: Mike Cunningham    15 Jun 2005Member 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 2005Member 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


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: NET Remoting Versus Web Services
Previous Resource: Cleaningup something using GarbageCollector
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use