SharePoint allows you to attach event receivers to content types. That’s pretty handy. Unfortunately, deleting event receivers from those content types is much more hard. Perhaps this is why the Document ID feature fails to remove the content types that it adds. However, here is one possible approach.
SPContentType ctype = site.RootWeb.ContentTypes[SPBuiltInContentTypeId.Document];
if (ctype != null)
if (ctype.EventReceivers != null)
bool bContinueDelete = true;
if (ctype.EventReceivers.Count < 1)
bContinueDelete = false;
bool bFoundOne = false;
foreach (SPEventReceiverDefinition d in ctype.EventReceivers)
//Could match on the Type of the event receiver, but for this example, let's use name
if (d.Name.Contains("Document ID"))
bFoundOne = true;
bContinueDelete = false;
More on why this is important in a later post.
I came across a question on StackOverflow about how to programmatically deploy a sandbox solution, and this seemed a good question. Here’s what I came up with…
Continue reading “Deploy a solution to the sandbox in C#”
Okay, this one was weird. The symptom is this – I had a custom Application page that was being used as the New and Edit forms for a particular custom list in my solution. One of the customisations was that it had an ‘Address Search’ button that, when you pressed, searched for an address based on the first line of the address, or the postcode.
That’s fine, but here’s where things got weird.
- If you were using the form as a New form, then search worked just fine the first time you clicked it.
- If you were using the form as an Edit form, the the search button didn’t work the first time you use it – but did the second time you clicked on it.
Bizarre, and I had to fix it… Continue reading “Strange issue with Application Page and Two Button Presses”
Hmm. Interesting problem – I had a Content Query Web Part (CQWP) that was displaying the Title for Discussions. Unfortunately when you clicked on them, they took you to the display form for the start of the thread, not the entire thing:
Okay, but could I get it to link to a view of the discussion thread itself?
Continue reading “CQWP and Discussions”
An interesting question came up on StackOverflow – how do you get the web application level policies for a Web app? In other words, the rights that you can grant to an entire web application (via central administration) – how do you get those in code?
Continue reading “Programmatically evaluate SPWebApplication Policies”
One of our customers had a penetration test performed on their SharePoint system. I think it’s fairly standard, but it could have a custom login form. In fact, given some of the errors, I think it must have been – but I had little involvement, so I’m not sure. Heck, it could even have been a SharePoint 2007 system, or a new login form that we didn’t write.
Either way, I thought it would be interesting (and a good reminder) to look at some of the issues it threw up… Continue reading “Results of Penetration Test on SharePoint system”
Following on from yesterday’s post about the difference between Check-Out and Locking in SharePoint, I found myself wondering what happens if you violate a lock? Or a Check Out? Let’s look at locks first… Continue reading “Check-Out, Locking and Document Co-authoring”