I'm trying to add the content of a user control dynamically at run time,
dependent upon some request attribute.
My user control is a simple tell-tall so I'm sure that's not spoiling
anything.
<%@ Control Language="C#" AutoEventWireup ="true"
CodeBehind="cpS tatus.ascx.cs" Inherits="uc.cp Status" %>
<p>status indicator for special users</p>
In my master page I have this...
<%@ Master Language="C#" AutoEventWireup ="true" CodeBehind="pla in.master.cs"
Inherits="mp.pl ain" %>
<asp:ContentPla ceHolder ID="FirstSideBa rContainer" runat="server">
<!-- side bar may be empty -->
</asp:ContentPlac eHolder>
and in the master page's code behind I have this...
protected void Page_Load(objec t sender, EventArgs e)
{
if (true == true)
{
ContentPlaceHol der ph1;
uc.cpStatus uc1;
ph1 = (ContentPlaceHo lder)FindContro l("FirstSideBar Container");
uc1 = new uc.cpStatus();
ph1.Controls.Ad d(uc1);
}
}
I can step through and debug and every line gets executed without error.
When ph1 is initialized its value is null. When it's assigned the value of
the ContentPlaceHol der contol found by name it has a control count of 1
(that must be the HTML comment asa text node). After the
ph1.Controls.Ad d(uc1) statemment it has a control count of 2, so my user
control would seem to have been added successfully but nothing (other than
the original comment) appears in my placeholder in my page.
What am I doing wrong?
dependent upon some request attribute.
My user control is a simple tell-tall so I'm sure that's not spoiling
anything.
<%@ Control Language="C#" AutoEventWireup ="true"
CodeBehind="cpS tatus.ascx.cs" Inherits="uc.cp Status" %>
<p>status indicator for special users</p>
In my master page I have this...
<%@ Master Language="C#" AutoEventWireup ="true" CodeBehind="pla in.master.cs"
Inherits="mp.pl ain" %>
<asp:ContentPla ceHolder ID="FirstSideBa rContainer" runat="server">
<!-- side bar may be empty -->
</asp:ContentPlac eHolder>
and in the master page's code behind I have this...
protected void Page_Load(objec t sender, EventArgs e)
{
if (true == true)
{
ContentPlaceHol der ph1;
uc.cpStatus uc1;
ph1 = (ContentPlaceHo lder)FindContro l("FirstSideBar Container");
uc1 = new uc.cpStatus();
ph1.Controls.Ad d(uc1);
}
}
I can step through and debug and every line gets executed without error.
When ph1 is initialized its value is null. When it's assigned the value of
the ContentPlaceHol der contol found by name it has a control count of 1
(that must be the HTML comment asa text node). After the
ph1.Controls.Ad d(uc1) statemment it has a control count of 2, so my user
control would seem to have been added successfully but nothing (other than
the original comment) appears in my placeholder in my page.
What am I doing wrong?
Comment