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…
Strange issue with Application Page and Two Button Presses
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”
CQWP and Discussions
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?
Programmatically evaluate SPWebApplication Policies
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”
Results of Penetration Test on SharePoint system
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”
Excel in SharePoint and "File is Corrupt" Error
This issue has caught me out several times – but if you’re using Excel on the SharePoint server – which is common during development – you need to turn off the protected views in the ‘Trust Center’ settings of Excel:
I’ve been set straight on this issue at least twice thanks to this post by JOPX. Unless those protected views are turned off then if you download the file you will only be told the file is corrupt – even if you can download the file and open it without any problem.
Check-Out, Locking and Document Co-authoring
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”
SharePoint: Check-Out vs Lock
I had been asked to look at a SharePoint event receiver that wasn’t behaving as it should. After a document had been checked in, it would set a property and update the item. However, we were getting an error:
SPException: The file “[File Name]” is locked for exclusive use by [User]
This was unfortunate – the user was the user who’d just been making changes, and the code was running after the document had been checked in – so what gives? Well, it turns out that the message is right – the file is locked, not checked out, and a lock is not the same as a check-out.
Continue reading “SharePoint: Check-Out vs Lock”
Getting and Setting Properties in SharePoint
In SharePoint there are “property bags” on many elements of the system. For example, SPWebs and SPFolders have them, and methods like GetProperty() and SetProperty() to set them.
These methods accept and return objects. However, it’s nice to get values back in the same form as they were set. Continue reading “Getting and Setting Properties in SharePoint”
Lookbehinds, Regexes, and replacing n
This is a little note for myself; don’t forget lookbehinds (and lookaheads) in regular expressions as a way of matching text that you don’t want to replace.
For example, if converting new lines to carriage-return new-lines:
// n ---> rn string output = Regex.Replace(input, "(?<!r)n", "rn");
This pattern find any new line character ‘n‘ and checks if the preceding character ‘(?< … )‘ is not a carriage return ‘!r‘.
This is neater than my having a capture group for the preceding character, and then having to put that group into my replacement pattern.


