Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Can someone tell me how I can load a user control from within another user control.

I'm using MOSS 2007

share|improve this question

1 Answer 1

I got the following code from the MDSN on line libray:

<%@ Page Language="C#" %>
<%@ Reference Control="~/Controls/Spinner.ascx" %>
<script runat="server">
private ASP.Spinner Spinner1
protected void Page_Load(object sender, EventArgs e)
{
  Spinner1 = (ASP.Spinner)LoadControl("~/Controls/Spinner.ascx");
}
protected void Button1_Click(object sender, EventArgs e)
{
  PlaceHolder1.Controls.Add(Spinner1);
}
</script>

<asp:PlaceHolder runat="server" ID="PlaceHolder1" />
<br />
<asp:Button ID="Button1" runat="server" Text="Click to Add User Control" OnClick="Button1_Click" />

basically you have to load the new control code behind and attach it in a place older so you have to set a PlaceHolder in the first control or something that can contains the Child-Control

This is the MSDN ref: http://msdn.microsoft.com/en-us/library/c0az2h86(v=vs.100).aspx

share|improve this answer
    
no working thanks but no thank you –  Customized Name May 9 '13 at 15:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.