Web Designer Friendly Web Parts
UPDATE:
My colleague, Lauri, went further after we discussed the method described in this article, and he generalized the process of making Visual Web Parts. I really like his approach more, as it also solves the problems with web part connections and the “double refreshing” problem, so please consider this article as obsolete and look at the better approach.
Web Designer friendly web parts, or web parts that are developed using web designer editable user controls, is a very old problem, and the web is already full of the solutions. One of the most known solutions is SmartPart for SharePoint. We had some issues of not-invented-here syndrome here at Sininen Meteoriitti, so we developed our own code to overcome the same problem. The code is very simple:
{
protected override void CreateChildControls()
{
base.CreateChildControls();
var control = Page.LoadControl(
"~/_controltemplates/XxxProject/XxxUserControl.ascx");
control.Init += (sender, e) =>
{
var uc = control as XxxUserControl;
if (uc == null && control is PartialCachingControl)
{
uc = ((PartialCachingControl)control).CachedControl as
XxxUserControl;
}
if (uc == null) return;
// Pass Web Part properties etc. to the user controls here:
// (the code below is provided as an example)
uc.MaxItems = 10;
uc.SearchScope = "All Sites";
};
Controls.Add(control);
}
}
Popularity: 8% [?]
[...] discussed an approach for creating Web Parts backed by a single user control in a previous post. While the approach works, it’s not quite perfect [...]
You have made some really good points there. I looked on the
net for more inhfo about the issue annd fkund most people will go
along with your views oon this site.
Thanks for your blog post. After attending SharePoint Saturday Ottawa (Canada), I was wrdoening if our organization could jump to SP2013 instead of 2010 in 2013 (the year). Since demos showed improvements in the social tools, I thought that most of our users would adopt SP more quickly and completely. Your revelation about limited user documentation makes me want to waver but who reads the documentation anyway? Regardless of which version, I hope to have guidance from a SharePoint consultant with best practices, revisiting governance and getting it right.
Beneficial facts. Privileged us I ran across your blog by accident, using this program .. web page designer stunned the reason why this kind of coincidence decided not to happened before hand! We book marked that.