.NET

Custom code with SharePoint Online and Windows Azure

When I first heard about SharePoint Online at the PDC 2008 I was a bit disappointed that you could not use custom code but had to rely on the built-in functionality and the things you could do with SharePoint Designer (which is quite powerful anyway, especially with jQuery). To read more about SharePoint online, head over to Tobias Zimmergrens blog. But with some clever techniques you can take advantage of the Windows Azure Hosted Services and create your custom code. I will show you how to create some custom code, which normally is done by SharePoint event receivers or timer jobs, using a Worker Role in Windows Azure.

.NET

Web Part Properties - part 2 - Editor Parts

This is the second part of the Web Part Properties series. The last post walked through the basics on how to make editable properties on a Web Part. As a sample I used a Web Part that displayed tweets from Twitter - called TweetPart. Using the standard approach, by marking the properties using specific attributes, we made the Web Part editable as we wanted. But the user experience, for editing, was not optimal. First of all the properties we wanted to edit was located in their own category at the bottom, not that easy to find for inexperienced/untrained users. Secondly the properties has dependencies and requires validation.

.NET

Web Part Properties - part 1 - introduction

I thought that I should kick off this new year with a series of posts on how to make your SharePoint Web Parts editable and how to enhance that out-of-the-box Web Part property editing combined with some tips and tricks. This first post may be to most of you SharePoint developers somewhat basic, but I have chosen to start from scratch here. Many of this first post topics are repeatedly asked in the MSDN development forums. The documentation in the SharePoint SDK on this topic is really bad; it just says do this and do that, never why you should do it. Often this makes developers unaware of pitfalls or possibilities.

.NET

PDC 2008: Day 1 and Windows Azure

Back at the hotel and watching some Monday Night Football (which I could do that in Sweden!). Here is a summary and some reflections on my day. Woke up early and walked down to LA Convention Center and got me some breakfast (tomorrow I’ll eat at the hotel). I tried to get to the keynote hall as early as possible for some good seating. I ended up in 6th row and had a good overview of the stage and the huge screens. As this is my first PDC and first conference of this magnitude I’m really impressed with the size and organization of it all.

.NET

How to sort XML without XSL in the .NET Framework

I have several times needed a way to sort XML, retrieved from a file or a web service, inline without invoking XSL transformations, which is the most common way to do it as I have seen. The .NET Framework contains the System.Xml.XPath namespace and is available from the .NET Framework 1.1 and up. This namespace contains a number of classes which can improve the performance of your .NET classes when working with XML. Specifically the System.Xml.XPath.XPathExpression contains a method (System.Xml.XPath.XPathExpression.AddSort) to sort the XPath query results.

.NET

Smooth upgrade of .NET XSL transformations from 1.1 to 2.0 or higher

When .NET 2.0 was introduced, quite a long time ago, the whole System.Xml namespace was re-written, due to the poor performance of the System.Xml implementation. Despite the fact that the CLR 2.0 has been around for a few years there are still implementations using CLR 1.x and especially the XSL transformation bits, since that part is completely re-written and marked as obsolete. But note that they are only being marked as obsolete! You can still compile and run most of the code with just a compiler warning. The old .NET 1.1 classes are still in the CLR 2.0, so you can convert your XSL transformations piece by piece and start using .NET 2.0 or even .NET 3.5 since it is based on .CLR 2.0 (read this post by Scott Hanselman to get a better understanding).

.NET

Using the new ListView control in SharePoint

The Microsoft .NET Framework 3.5 contains a great new ASP.NET control called ListView. When using the ListView control you have much more control over how the output HTML will look like, which I think still is the main problem with the ASP.NET controls. To learn more about the ListView control, head over to Mustafa Basguns blog and read his excellent articles on the control. The ListView control is great when working with SharePoint (WSS3 and/or MOSS 2007) custom pages, since designing SharePoint pages which adapts into the current administration or takes advantage of all the CSS styles demands you to have pretty good control of your HTML.

.NET

Dissecting XPS, part 6 - reading XPS files programatically

The sixth part of the Dissecting XPS series is here and this time we will, finally, look at some code for reading XML Paper Specification [1], XPS, files. I will in the following sample not use the Microsoft.NET 3.0 Framework, which has built-in functionality for reading and writing XPS files [2]. Instead I will do it using .NET 2.0 (you can try it in .NET 1.1 if you like) and an excellent ZIP library called #ziplib [3]. This will show you more of what’s really happening and it will show you how to integrate XPS into applications built using other .NET Frameworks than 3.0 or in Mono or in what ever you like. For instance, you can use Java and the Java Zip packages.

.NET

A Cheat sheet of Cheat sheets

Here is a list of cheat sheets for the Windows and .NET platform that I frequently use and I think are of great interest. Visual Studio 2005 Keyboard Shortcut References Visual C# 2005 - PDF grayscale | PDF color Visual C++ 2005 - PDF grayscale | PDF color Visual Basic 2005 - PDF grayscale | PDF color SharePoint and Office stuff CSS Reference Chart for SharePoint 2007 (Microsoft Office SharePoint Server 2007 and Windows SharePoint Services v3) CSS Reference Chart for SharePoint 2003 New Office 2007 User Interface - Word | PDF Web and ASP.NET stuff Microsoft AJAX ClientScript Cheat Sheet - ZIP JavaScript Cheat Sheet - PNG | PDF Other stuff

.NET

Updated: Even better encapsulation of getting a value from XmlNode

I previously suggested a better method for getting attributes for an System.Xml.XmlNode in a response to an post by Marcus. Craig Nicholson highlighted in a comment that the code i provided can be even further optimized. private static string GetAttribute(XmlNode node, string name) { XmlElement elm = node as XmlElement; return (elm == null) ? string.Empty : elm.GetAttribute(name); } .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, “Courier New”, courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }

.NET

Preventing comment spam using LinkSleeve

I have a lot of problem with comment spam on the blog as well as spamming on the trackbacks and the problem is spread widely over the blogging world. A lot of you turn off comments or have registration or other methods to get rid of the comment spamming. LinkSleeve (SLV - Spam Link Verification) is a link spam solution that checks a text for well-known URL’s in a text and tells if it contains any known spam addresses. This service is provided via an XML-RPC service without any licensing.

.NET

Even better encapsulation of getting a value from XmlNode

Marcus writes in his blog how he often ends up with a method that reads an attribute from an XmlNode object. He has optimized his method so that the exception handling will be minimal, since that is pretty expensive. This is a pretty common scenario for me and I have an even better solution, that does’nt involve exception handling at all. private static string GetAttribute(XmlNode node, string name) { XmlElement elm = node as XmlElement; if (elm == null) { return ""; } return elm.GetAttribute(name); } This method uses the C# as operator which cast the XmlNode to an XmlElement, if it fails it will return null instead of invoking exception handling.

.NET

XML Notepad 2006 - what's the fuzz about?

There seems to be some kind of software release frenzy at Redmond right now. Microsoft are spitting out application after application and I don’t mean the two huge ones; MIcrosoft Windows Vista and Microsoft Office (Server) System. Applications, small and big, like Internet Explorer 7, Windows Live Writer, XNA Game Studios, different Microsoft Live applications, Windows Desktop Search and now XML Notepad 2006 are dropping out from the software factory. It’s fun, but it takes me so much time reading and catching up on the releases.

Microsoft Expression

First Impression of Microsoft Expression Web Designer

So, after some installation trouble the Microsoft Expression Web Designer was installed, read more about it in the EWD Discussion group.The Expression Web Designer is for me a new and improved FrontPage more focused on the layout. I made some initial pages/sites and I feel that it works pretty smoothly to work with. The target group for this product is purely front-end/html programmers.The EWD will complement the Visual Studio development but the lack of source control integration is not just irritating - it’s a “application breaker”. I think the usage of EWD when building large and complex projects will not be that high if this is not implmented. I think my company will still be using Visual Studio for editing webpages for a while….I also lack a nice integration with the Expression Graphics Designer, it would be nice to right-click an image and open the EGD editor within EWD! (When is the next CTP/beta/Gold for EGD coming???) But, I think I’ll give it a shot and try to use it some more before I give it my final judgement. Do you agree or disagree?

.NET

Updated ComPlusWrapper class

Here is an updated version of the ComPlusWrapper that I previously published, this one contains a Hashtable for caching the ProgId/Types as well as a method for invoking methods.Please post any comments to the code or any improvments to the class. public class ComPlusWrapper : IDisposable { private static volatile Hashtable s_types = new Hashtable();private static volatile Object s_lock = new Object();private object _ComPlusObject; private Type _type;private bool _IsDisposed = false;