Question

for example the user control i created is a dock panel, and i want to make it to allow add others controls from aspx page.

<uc1:dockPanel ID="dockPanel1" runat="server" >
  --add control to here from aspx page--
</uc1:dockPanel>
Was it helpful?

Solution 2

in my research i found something like this.. so we can add an inner property inside the WebUserControl, for example.. but the problem that i facing now is the control is not render inside WebUserControl, its render in the page.

HTML

 <uc1:dockPanel ID="dockPanel1" runat="server">
            <ContentTemplate>
                <dx:ASPxButton ID="ASPxButton1" runat="server" Text="ASPxButton">
                </dx:ASPxButton>
            </ContentTemplate>
        </uc1:dockPanel>

ASCX [ParseChildren(true)]

public partial class dockPanel :System.Web.UI.UserControl, INamingContainer
{

    [PersistenceMode(PersistenceMode.InnerProperty)]
    [TemplateContainer(typeof(dockPanel))]
    public ITemplate ContentTemplate { get; set; }

     protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            if (ContentTemplate != null)
                ContentTemplate.InstantiateIn(this);
        }
}

OTHER TIPS

You load controls dynamically via control.add method. First get an object of user control and then use control.add property for that.

See following link for the reference. http://msdn.microsoft.com/en-us/library/aa287574(v=vs.71).aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top