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
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
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
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
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
The Holy Grail of SharePoint branding - at least as far as I’m concerned – is rounded corners on Web Parts. Every design that comes in has this at first. As mentioned yesterday there are examples of doing this for the web part’s title - I’ve done this using Madalina’s instructions and Heather Solomon has some instructions too.
However, as far as I know nobody has yet figured out a way of putting rounded corners on the bottom corners of web parts. The HTML they have does not suit them to do this via CSS. The only idea I’ve had previously was to use ControlAdapters to modify the output of of the Web Part itself. And I’m pretty sure you’d have to write an adapter per web parts. That kind of sucks; no customer is going to be in a hurry to pay for that.
Well, when I was looking at putting borders around an entire web part zone, I had a thought. What we really need to do is insert elements into our page. jQuery can do that sort of thing. Could I use jQuery to find each web part and wrap some tags around it? Continue reading
Ages ago I observed that the ‘Add New Document’ link in a summary toolbar takes you to an ‘Upload’ page, rather than creating a new document based on that template, and suggested doing something about that. That was a bit of a hack, though, so now I’ve written a web part to allow you to display ‘Add new…’ links and if you click on them, it opens up a new document based on that content type’s template. I’ve called it the ‘Create New Document Web Part’
Curious problem this – I had a web part zone where all web parts being put in it would be displayed without their titles. Didn’t matter if you manually went and turned on the chrome to show a title – that setting never saved, and the web parts didn’t ever have a title.
After tracking through all the page’s code, I found that when I set the WebPartZone’s ID to be ‘Main’ then my web parts ceased functioning correctly; their titles disappeared. If I set the ID back to ‘Left’, then all was fine.
I don’t know why this happens, but certainly using a different ID for my zone fixes it. If anyone knows why this actually happens, please let me know.