T
tshad
I am trying to access a control (PlaceHolder Control) that is in a
dynamically loaded control. I know it is there as I can see it in my trace.
It may be that it isn't actually loaded yet - but not sure.
In the following page, I am loading a page called "page.aspx" into a control
called pageControl. This page also has an asplaceHolder control with an
"ID=Content".
I am trying find this PlaceHolder so I can load another control into it's
controls array. But when I do a FindControl from the Forms Control - it
can't find it. But it is part of Forms Control (I think) as you can see
from the trace.
The message I am getting is: "contentControl is Nothing"
Is this the wrong way to do this?
****************************************
<%@ Page Language="VB" trace="true" debug="true" ContentType="text/html"
ResponseEncoding="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<script runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
Dim thePage as String
Dim pageControl as Control
Dim contentControl as Control
Dim a as htmlControl
thePage = "Page.ascx"
pageControl = LoadControl(thePage)
thePlaceHolder.Controls.Add(pageControl)
a = CType(Page.FindControl("addForm"),htmlControl)
contentControl = CType(a.FindControl("Content"),Control)
If ContentControl is Nothing then
trace.warn("contentControl is Nothing")
else
trace.warn("contentControl is Something")
end if
end Sub
</script>
<html>
<head>
<title>:</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<body id="myBody" leftmargin="0" topmargin="0" marginwidth="0"
marginheight="0" runat="server">
<form id="addForm" runat="server">
<asplaceHolder ID="thePlaceHolder" runat="server"/>
</form>
</body>
</html>
****************************************
__PAGE ASP.DisplayCompanyJobs3_aspx
_ctl1 System.Web.UI.LiteralControl
_ctl2 System.Web.UI.LiteralControl
myBody System.Web.UI.HtmlControls.HtmlGenericControl
_ctl3 System.Web.UI.LiteralControl
addForm System.Web.UI.HtmlControls.HtmlForm
_ctl4 System.Web.UI.LiteralControl
thePlaceHolder System.Web.UI.WebControls.PlaceHolder
_ctl0 ASP.ftsPage_ascx
_ctl0:_ctl0 System.Web.UI.ResourceBasedLiteralControl
_ctl0:Navigation System.Web.UI.WebControls.PlaceHolder
_ctl0:_ctl1 System.Web.UI.LiteralControl
_ctl0:Content System.Web.UI.WebControls.PlaceHolder
_ctl0:_ctl2 System.Web.UI.ResourceBasedLiteralControl
_ctl5 System.Web.UI.LiteralControl
UserLoggedOnLabel System.Web.UI.WebControls.Label
_ctl6 System.Web.UI.LiteralControl
UserLoggedOn System.Web.UI.WebControls.Label
_ctl7 System.Web.UI.LiteralControl
_ctl8 System.Web.UI.LiteralControl
_ctl9 System.Web.UI.LiteralControl
Thanks,
Tom
dynamically loaded control. I know it is there as I can see it in my trace.
It may be that it isn't actually loaded yet - but not sure.
In the following page, I am loading a page called "page.aspx" into a control
called pageControl. This page also has an asplaceHolder control with an
"ID=Content".
I am trying find this PlaceHolder so I can load another control into it's
controls array. But when I do a FindControl from the Forms Control - it
can't find it. But it is part of Forms Control (I think) as you can see
from the trace.
The message I am getting is: "contentControl is Nothing"
Is this the wrong way to do this?
****************************************
<%@ Page Language="VB" trace="true" debug="true" ContentType="text/html"
ResponseEncoding="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<script runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
Dim thePage as String
Dim pageControl as Control
Dim contentControl as Control
Dim a as htmlControl
thePage = "Page.ascx"
pageControl = LoadControl(thePage)
thePlaceHolder.Controls.Add(pageControl)
a = CType(Page.FindControl("addForm"),htmlControl)
contentControl = CType(a.FindControl("Content"),Control)
If ContentControl is Nothing then
trace.warn("contentControl is Nothing")
else
trace.warn("contentControl is Something")
end if
end Sub
</script>
<html>
<head>
<title>:</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<body id="myBody" leftmargin="0" topmargin="0" marginwidth="0"
marginheight="0" runat="server">
<form id="addForm" runat="server">
<asplaceHolder ID="thePlaceHolder" runat="server"/>
</form>
</body>
</html>
****************************************
__PAGE ASP.DisplayCompanyJobs3_aspx
_ctl1 System.Web.UI.LiteralControl
_ctl2 System.Web.UI.LiteralControl
myBody System.Web.UI.HtmlControls.HtmlGenericControl
_ctl3 System.Web.UI.LiteralControl
addForm System.Web.UI.HtmlControls.HtmlForm
_ctl4 System.Web.UI.LiteralControl
thePlaceHolder System.Web.UI.WebControls.PlaceHolder
_ctl0 ASP.ftsPage_ascx
_ctl0:_ctl0 System.Web.UI.ResourceBasedLiteralControl
_ctl0:Navigation System.Web.UI.WebControls.PlaceHolder
_ctl0:_ctl1 System.Web.UI.LiteralControl
_ctl0:Content System.Web.UI.WebControls.PlaceHolder
_ctl0:_ctl2 System.Web.UI.ResourceBasedLiteralControl
_ctl5 System.Web.UI.LiteralControl
UserLoggedOnLabel System.Web.UI.WebControls.Label
_ctl6 System.Web.UI.LiteralControl
UserLoggedOn System.Web.UI.WebControls.Label
_ctl7 System.Web.UI.LiteralControl
_ctl8 System.Web.UI.LiteralControl
_ctl9 System.Web.UI.LiteralControl
Thanks,
Tom