Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.
  1. I created user control1.ascx and put in controls template folder
  2. then add visual webpart in the visual webpart ascx control1.ascx i registered in visual webpart ascx control and the deployee but sharepoint visual webpart not displaying control1.ascx
share|improve this question

2 Answers 2

I suppose you might need to do the same thing for your inner control that the webpart itself does for its control:

// Visual Studio might automatically update this path when you change the Visual Web Part project item.
        private const string _ascxPath = @"~/_CONTROLTEMPLATES/ControlInsideControlWebPart/VisualWebPart1/VisualWebPart1UserControl.ascx";

        protected override void CreateChildControls()
        {
            Control control = Page.LoadControl(_ascxPath);
            Controls.Add(control);
        }

But it will be in the Page_Load event of you visual web part user control.

share|improve this answer

Check your declaration there are should be 3 main parts in the ascx file:

  1. Tag registration - <%@ Register TagPrefix="mycontrol" TagName="simplecontrol" Src="~/_CONTROLTEMPLATES/mycontrol.ascx" %>
  2. Reference to assambly which contains code behinde of your control- <%@ Assembly Name="assemblyname" %>
  3. Control declaration to markup - <mycontrol:simplecontrolID="simplecontrol" runat="server" />
share|improve this answer

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.