tags:

views:

8

answers:

1

I want to add my user control in InstantiateIn like this:

public void InstantiateIn(Control container)
    {
        PIMVisualizer pimVisualizer = new PIMVisualizer();
        container.Controls.Add(pimVisualizer);
        container.Controls.Add(new Button() {Text="asdf"});
    }

but the control doeas not appear on the page (the button does). The control is trivial, I am just testing the approach:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="PIMVisualizer.ascx.cs" Inherits="PIMVisualizer" %><asp:Label ID="Label1" runat="server" Text="UC"></asp:Label>

but still, why does not the text "UC" appear onthe page?

A: 

You have to load UserControls, do not create them via constructor.

Tim Schmelter