Hmm – and interesting problem; in the Sandbox you don’t have any access to the CssRegistration class. It’s in the Microsoft.SharePoint.WebControls namespace, and you don’t have access to that.
<Link> tag into the
<Head> of the page.
Clever, but yuck! Continue reading “No CssRegistration control in Sandbox”
Remarkably, I’ve only just started doing my first Sandboxed development in SharePoint 2010. (Most of our customers own their own servers, and want functionality you can’t easily build in the Sandbox alone).
Anyway, I knew that the API you could use in the sandbox was smaller than the full API, and I wanted my solution to warn me (e.g. fail to compile) if I tried to use something that wasn’t available in the sandbox. I found two approaches… Continue reading “Sandbox Development – Reference the User Code DLL”
I had a slightly unusual situation. We’ve a customer who has using the Telerik RadEditor version 4.5.6 for SharePoint 2007. They’re upgrading to SharePoint 2010, and want their existing content to continue to work.
They’ve using the Telerik RadEditor web part quite a lot, so we had to keep that working. We’ve put in Assembly Binding Redirects using an SPWebConfigModification (more on that in a later post).
However, we also needed to put in the SafeControl entry for the old assembly. Continue reading “SafeControls Entries in Manifest can be changed during deployment”
Something that has bothered me repeatedly in the past is that ListViewWebParts didn’t seem to allow their titles to be set via CAML. The View element for a site (i.e. in the ONET.xml file) doesn’t have a title element, and the ‘Name’ and ‘DisplayName’ elements don’t set the web part’s title. Instead, the ListViewWebPart always seemed to pick up the name of the list it referred to. This was a problem if you had a page that showed two ListViewWebParts refering to the same list. E.g.:
<View List="Lists/Tasks" BaseViewID="7" WebPartZoneID="Left" WebPartOrder="5" />
<View List="Lists/Tasks" BaseViewID="9" WebPartZoneID="Left" WebPartOrder="6" />
would result in:
How can we set those titles to be different? Continue reading “Set the Title of a ListViewWebPart”
I had a requirement recently to display the fields of a SharePoint item in another SharePoint site. Now, you can do this with things like the Content Query Web Part, or Data View Web Part, but I was doing a few other things, and specifically, I needed to pull the fields to display from a particular View on the list.
This turned out to be quite an interesting problem. All fields use a subclass of BaseFieldControl, and this is what renders the field – so it appeared to be fairly straight forward. As always, though, there was a little kink to it – you need an SPContext for the site the item comes from, and you need to use this as the contexts for the SPField‘s rendering control:
SPContext ctx = SPContext.GetContext(HttpContext.Current, item.ID, relatedList.ID, relatedWeb);
SPView relatedView = list.DefaultView;
foreach (string vf in relatedView.ViewFields)
SPField fld = relatedList.Fields.GetFieldByInternalName(vf);
HtmlGenericControl titleLabel = new HtmlGenericControl("H3");
titleLabel.InnerText = fld.Title;
this.Controls.Add( titleLabel );
BaseFieldControl ctl = fld.FieldRenderingControl;
ctl.ControlMode = SPControlMode.Display;
ctl.ListId = relatedList.ID;
ctl.ItemId = item.ID;
ctl.RenderContext = ctx;
ctl.ItemContext = ctx;
ctl.FieldName = fld.Title;
ctl.ID = Guid.NewGuid().ToString();
this.Controls.Add( ctl );
Came a cropper on this one today – using web parts based on System.Web.UI.WebControls.WebParts.WebPart in a Site Definition. Unlike the Microsoft.SharePoint.WebPartPages base web part, ASP.NET 2.0 ones need a
<webParts /> tag around your
<webPart> tag – other wise you get the error:
Cannot recognize the xml namespace of this web part
Joris Poelmans has a good description of the problem, and that was where I read the solution – it saved me a tonne of time.
It’s well known, but mostly to remind myself – if you’ve got a web part that causes problem on a page (like the yellow screen of death) and you want to remove it, add the following to your url:
Takes you to the Web Part Maintenance Page. I can never remember the bit you add to the URL