By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,333 Members | 1,850 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,333 IT Pros & Developers. It's quick & easy.

placeholder

P: n/a
2 questions please.

1) if i make a placeholder invisible or remove it programmatically
does that mean its contents wont get loaded. e.g. lets say i had a
heavy datagrid within the placeholder which took a few seconds to
load. if i made the placeholder invisible does that mean the grid
would not get loaded at all so the page would load quicker?

2) can you remove a placeholder programmatically?

thanks.

Nov 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi,

The control won't render to the client (Browser) but binding on the
server side would take place. So there will be performance improvement.
You can improve your performance if you won't create and bind your
control at all. Consider the following code :

System.Collections.ArrayList oArr = new System.Collections.ArrayList();
for(int i = 0; i< 11 ; i++)
{
oArr.Add("string " + Convert.ToString(i) );
}

ListBox o = new ListBox();
o.Visible = true;
o.DataSource = oArr;
o.DataBind();
PlaceHolder2.Controls.Add(o);

I create dynamic listbox and add it to Placeholder. I can remove place
holder programmatically:

this.FindControl("Form1").Controls.Remove(PlaceHol der2);

causing the datalist won't be render to the client. But I can use the
same condition and instead of removing place holder simply not to create
DatatList.

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #2

P: n/a
Jos
Wee Bubba wrote:
2 questions please.

1) if i make a placeholder invisible or remove it programmatically
does that mean its contents wont get loaded. e.g. lets say i had a
heavy datagrid within the placeholder which took a few seconds to
load. if i made the placeholder invisible does that mean the grid
would not get loaded at all so the page would load quicker?
When you make it invisible:
the content gets loaded. The content will not be shown, but
its state will be added to viewstate.

When you remove it programmatically:
the content doesn't get loaded.
2) can you remove a placeholder programmatically?


Yes. In VB:
Page.Controls.Remove(Page.FindControl("IDofMyPlace Holder"))

--

Jos
Nov 18 '05 #3

P: n/a
thanks guys. in my case i think i need to remove this programmatically
then becauser there's no point loading my contents if im not going to
display them.

thanks for the advice.

Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.