Y
Yourself
I have the following .aspx code:
<%@ Page Language="vb" AutoEventWireup="false" Explicit="True"
Inherits="Whatever.DefaultPage" CodeFile="Default.aspx.vb" %>
<%@ Register TagPrefix="whatever" TagName="something"
Src="~/Whatever/Whatever.ascx" %>
<asplaceholder id="fred" runat="server"></asplaceholder>
<whatever:something id="something" runat="server" />
the Default.aspx.vb code adds some controls to the 'fred' placeholder in the
Page_Init method.
I want to remove all of the controls added to the 'fred' placeholder, within
my user control 'whatever:something'.
My Whatever.ascx.cs Page_Init method looks like this:
// get the fred placeholder (this line works and returns a placeholder which
!= null)
System.Web.UI.WebControls.PlaceHolder fred =
(PlaceHolder)Parent.Page.FindControl("fred");
// clear all of freds controls
if (fred != null)
{
fred.Controls.Clear();
}
The fred.Controls.Clear() doesn't work, all of the controls that fred has
added (within Default.aspx.vb) are still there
Is it something to do with the order in which the Page_Init methods are
called? Are they called in any specific order?
Any ideas? Please help!
<%@ Page Language="vb" AutoEventWireup="false" Explicit="True"
Inherits="Whatever.DefaultPage" CodeFile="Default.aspx.vb" %>
<%@ Register TagPrefix="whatever" TagName="something"
Src="~/Whatever/Whatever.ascx" %>
<asplaceholder id="fred" runat="server"></asplaceholder>
<whatever:something id="something" runat="server" />
the Default.aspx.vb code adds some controls to the 'fred' placeholder in the
Page_Init method.
I want to remove all of the controls added to the 'fred' placeholder, within
my user control 'whatever:something'.
My Whatever.ascx.cs Page_Init method looks like this:
// get the fred placeholder (this line works and returns a placeholder which
!= null)
System.Web.UI.WebControls.PlaceHolder fred =
(PlaceHolder)Parent.Page.FindControl("fred");
// clear all of freds controls
if (fred != null)
{
fred.Controls.Clear();
}
The fred.Controls.Clear() doesn't work, all of the controls that fred has
added (within Default.aspx.vb) are still there
Is it something to do with the order in which the Page_Init methods are
called? Are they called in any specific order?
Any ideas? Please help!