March 2008 - Posts

Faceted Search Screencasts!!

For those of you that struggled with configuring Faceted Search (http://www.codeplex.com/FacetedSearch) of which I'm personally a huge fan, Microsoft released the two following video walkthroughs:

How to install it (http://video.msn.com/video.aspx?vid=bb8d1495-9c8e-4ee5-bde8-c326f70c5ea6)

How to configure it for Business Data Catalog - BDC (http://video.msn.com/video.aspx?vid=4c021182-b7a3-4520-944d-dc1e6fb3791d)

See original post about this here (http://blogs.msdn.com/sharepoint/archive/2008/03/19/open-source-faceted-search-how-to-screencasts-now-available.aspx)

Posted by Zlatan | with no comments

Debugging Web Parts in SharePoint 2007

Ok in my previous article I covered basic SharePoint 2007 Web Part Development, (this is another thing I've been asked a lot) one important thing when it comes to development especially more complex web parts is debugging and stepping through the code.

This is super easy so here you go....................

So..... you finished developing your Web Part, and you pressed Crtl+Shift+B and your Build went fine, but you get errors displayed when you test your Web Part in SharePoint 2007, so what do you do now?

1. First you right-click on your project file in the solution explorer and click on "Properties".

2. Then under the Build section you change the Output path to the bin directory in the Virtual Directory of the web application under which you want to debug your web part (this is another way to deploy your web parts besides already mentioned ways in my previous post http://dotnet.org.za/zlatan/archive/2008/03/25/developing-basic-web-parts-in-sharepoint-2007.aspx).

3. Build your project/solution (Crtl+Shift+B)

4. Next under Debug you select Attach to Process.

5. You select w3wp.exe from the list of processes (if there is more than one, then select them all just to be on the safe side).

 

6. I hope you didn't forget to put a break point in your code and now debug away.

Developing Basic Web Parts in SharePoint 2007

Many times in the past I've been asked to help and elaborate on one SharePoint topic and that is building Web Parts for SharePoint. I've talked about this in my community events as well as conferences where I presented. I've also blogged about some more advanced development of Web Parts but I've never done a more basic explanation of how to develop simple Web Parts. After this last request I finally gave in, so here it is.

Coolest thing about web parts in SharePoint is its complete utilisation of ASP.NET 2.0 platform and what it has to offer. SharePoint web pages are basically a combination of the precompiled DLL and a ASPX page. If you change and/or customize a page in SharePoint the changes are stored in the database, so the final ASPX page that you see is a combination of the original ASPX page and changes stored in a database.

 

Getting to the point of WebParts, webparts can be insanely easy to be make or they can drive you crazy if they're way too complex.

Very easy way to create (with AJAX) is actually described in my post which is actually done in VS2005 ( http://dotnet.org.za/zlatan/archive/2007/10/12/developing-ajax-web-parts-in-sharepoint-2007.aspx). Example also contains source code of the webpart I designed to show new tasks from the SharePoint task list as they arrive (without the need to refresh), this code can also be used to rotate news or other list items dynamically and many other things.

If you're not interested in using AJAX in your webparts then just ignore the instructions 1-3 and go to 4 (which is the very beginning of the code):

First, make sure you're using:

Visual Studio 2005 with Office SharePoint Server 2007 SDK 1.3 (or Windows SharePoint Services SDK 1.3) and Visual Studio 2005 extensions for Windows SharePoint Services 1.1.

http://dotnet.org.za/zlatan/archive/2008/03/09/sharepoint-server-2007-version-1-3-and-wss-3-0-version-1-3-available.aspx

http://dotnet.org.za/zlatan/archive/2008/02/13/final-release-of-vsewss-1-1-visual-studio-extensions-for-windows-sharepoint-services.aspx

You can also develop Web Parts with Visual Studio 2008, but without the templates (for the time being) that do help a lot, especially if you're a beginner.

 

1. Start the VS choose Web Part (template) under SharePoint section.

 

2. SharePoint WebPart inherits from an abstract base class called Microsoft.SharePoint.WebPartPages.WebPart, which inherits from System.Web.UI.WebParts.WebPart, so since you got two classes to choose from, which one do you choose?

Safe bet is the ASP.NET 2.0 abstract class, ie. System.Web.UI.WebControls.WebParts.WebPart. Anyway, that's the one that you'll see when your template loads.

 

3. You would be presented with the code below:

Next you override CreateChildControls to create the control tree, later override any other method from the System.Web.UI control class.

using System;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;

using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;

namespace WebPart1
{
    [Guid("720e3e34-4127-438b-a4fb-d159d5a082e7")]
    public class WebPart1 : System.Web.UI.WebControls.WebParts.WebPart
    {
        public WebPart1()
        {
        }

        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            // TODO: add custom rendering code here.
            // Label label = new Label();
            // label.Text = "Hello World";
            // this.Controls.Add(label);
        }
    }
}

 

4. Press F5 and when the Web Part is deployed add it on the SharePoint 2007 page from the library (if you don't specify otherwise then you'll find it under "Miscellaneous")

If you're using any earlier SDK or extensions, once you compile your WebPart Project follow these steps to deploy the solution:

1. First drag and drop the compiled assembly into the GAC (by default c:\windows\assembly).
2. Open the properties of the dll to get the public key token.
3. Now register the safe control in the web.config. (i.e. '<SafeControl Assembly="WebPartForYou, Version=1.0.0.0, Culture=neutral, PublicKeyToken=74e5f216d6256126" Namespace="WebPartForYou" TypeName="*" Safe="True" /> )

4. In SharePoint, click 'Site Actions', 'Site Settings' and then under 'Site Collection Administration' click 'Go to top level site settings'.
5. Under 'Galleries', click 'Web Parts'. Then click 'New'.
6. Now, the new webpart(s) will appear in the list. If not, try an IISRESET and refresh the page.
Select the webpart we've just created and click 'Populate Gallery'.

Now when you edit your SharePoint page you'll find your WebPart listed, most likely in Miscellaneous section, click to Add it and Voila.

 (note that if you're using the above SDKs and extensions, all of these steps above are done automatically for you).

Hope that this helps, it should get you started

SharePoint Server 2007 SDK version 1.3 and WSS 3.0 SDK version 1.3 Available

Remember that release of the service pack 1 for SharePoint Server 2007 and WSS 3.0? Well they released revised SDKs to fit the SP1 for both, both dubbed Version 1.3.

This is where you can download them:

SharePoint Server 2007 SDK: Software Development Kit (http://www.microsoft.com/downloads/details.aspx?FamilyId=6D94E307-67D9-41AC-B2D6-0074D6286FA9&displaylang=en)

Windows SharePoint Services 3.0: Software Development Kit (http://www.microsoft.com/downloads/details.aspx?familyid=05E0DD12-8394-402B-8936-A07FE8AFAFFD&displaylang=en)

If you're a SharePoint Dev (or if you want to be one) you'll need it, so just go and get it :)

SQL Server Database Mirroring with Office SharePoint Server and Windows SharePoint Services

Sometimes I lead a double (triple) life of being a SQL consultant guy. That guy that gets sent to recover lost and/or corrupt databases, troubleshoot, implement proper policies when it comes to SQL backup and maintenance (that DBA stuff), and above all architecting appropriate deployment of databases with different availability options. Yeah, and I'm one of those guys that thinks that Kimberly Tripp (http://www.sqlskills.com/blogs/kimberly/) is one of the coolest people on the planet.

I always found availability to be most fun when it comes to SQL servers (especially since 2005 came out).

You can have server level redundancy/availability, like active-active or active-passive, with your NICs, heartbeats, quorums, deploy your SQL Server on those and hope that you leave it with a patient and skilled enough admin that can take good care of it.

On the other side you can use database level redundancy that SQL 2005 gave you -> Mirroring (aka Hot Standby).

You got three types:

  • High Availability (synchronous) -> this is the one you want!!
  • High Protection/Safety (synchronous)
  • High Performance (asynchronous)

You also got good old Log Shipping (Warm Standby).

Don't worry about Cold Standby.

Now clients using and wanting SharePoint 2007 and WSS 3.0 so far have been a bit reluctant to further invest in availability options for their servers and databases (except the really big ones). Recently I had to figure out how to provide SQL 2005 high availability mirroring option and it kinda really felt good.

If you would like to do it (for a client of for fun), you'll need this document:

Using SQL Server Database Mirroring with Office SharePoint Server and Windows SharePoint Services (http://go.microsoft.com/fwlink/?LinkId=83725&clcid=0x409)

 

Microsoft Academic Alliance Installation Festival 2008 Africa Pilot Successful!!!!

 

Saturday (1st of March 2008) was the first day of the Microsoft Academic Alliance Installation Festival (pilot). We've had an attendance from Final Year and Post Graduate Information Systems and some Computer Science students from University of Cape Town. I've had an over 2 hour talk which started with new Visual Studio 2008 Development, and after that introduction to OBA, SharePoint, SOA and ESB (a lot of talking).

Nyaladzi Mpofu (from Microsoft Academic Alliance) gave his speech about Microsoft Academic Alliance involvement and support for Imagine Cup and we had a talk from South African winners and Imagine Cup finalists who are going to represent South Africa in France this year who also happen to come from UCT IS department, they are going to present an excellent GIS (shuttle tracking) solution.

On Tuesday (4th of March 2008) Hilton Giesenow (http://hilton.giesenow.com/) gave one of his excellent talks on development with LINQ and ASP.NET with VS 2008 for the same audience.

We've distributed DVDs with software that Microsoft Academic Alliance provided and gave some rewards for good questions.

Besides getting a really good response from the students, in their correspondence to me later they felt that there is great potential to increase the relationship between some of the communities like SADeveloper, Information Worker, SAArchitect and UCT.  They suggested that we could work on ways of setting up a forum or a mentorship programme whereby students could interact with different members of the SA dev community, and they felt that it would be a very handy tool for them as students because it would allow them to bounce ideas off people who are experts with their respective development environments.

I would like to thank Microsoft Academic Alliance, MVPs and our community who were very supportive of this initiative, also a big thank you goes out to UCT staff and students for welcoming us and making this pilot a success.

Success of this pilot means that this is just a great beginning to even more Microsoft Academic Alliance Installation Festivals at the Universities and Technikons all over South Africa.

It feels good to make a difference.

Posted by Zlatan | with no comments
Filed under: ,