I’m building a webpart for SharePoint 2010, but I’ve already created a repeater and a couple of methods executed on the Load method of the webpart’s user control.
Now, I want to include that control in the webpart, so I can see it in SharePoint, because I actually don’t see it, although I’m adding it to the webpart as follows, in the CreateChildControls method:
VisualWebPart1UserControl uc = new VisualWebPart1UserControl();
this.Controls.Add(uc);
What am I missing?
What you are doing is essentially manually creating a visual webpart.
The visual webpart template uses the following code to acheive this result:
You might want to consider just creating a visual webpart in Visual Studio and replacing the
.ascxfile with your control.