Podcasting Kit for SharePoint (PKS): a free add-on to MOSS 2007

Interesting release on CodePlex earlier this month: the Podcasting Kit for Sharepoint. This kit allows you to more easily integrate a podcasting solution into SharePoint 2007.

Current release is still pre-beta but they are planning to have a production ready release by Septebmer 2008.
 
Some of the features are:

  • Listen and watch audio/video podcasts, anywhere on your PC or mobile device (Zune, SmartPhone, or any podcasting device)
  • Share content by producing your own audio/video podcasts and publish them on PKS on your own.
  • Tag cloud
  • Comments
  • Rating system
  • Play podcasts in real-time using Microsoft® Silverligh and progressive playback
  • And more…

Definitely worth checking out before you think about creating your own solution from the ground up.

As the PKS uses WMV as a video format, you might also be interested in a side project, “Server Side Re-encoding for Podcasting Kit for SharePoint”, an add-on that converts several video and audio formats to WMV.

 

Technorati tags: , ,

 

 


Brussels Girl Geek Dinner #6 - on Paleo Futurism and Expo58

Just back from my second Brussels Girl Geek Dinner, this time at Lamot in Mechelen where we got the opportunity to have a visit to the Expo 58 exposition. It was really worth it!

But my top moment was the session on Paleo Future (what the ?). Paleo Future, according to Matt Novak who seems to have invented it, is "a look into the future that never was". Humm you might think, well actually it's a very interesting topic. It's the analysis on how people looked at the future, in the past. And mostly how they were wrong about it.

The session itself was not presented by Matt Novak, however he did actively help in putting it together with Peter Van Wijnaerde. Peter presented a session specially for the girls as he collected material treating the views people had on the future in regards to women. With that I learned that in the beginning of the 20th century they thought that women would be very powerfull, run for president, be very strong (as in big and not so girly) by the year 2000. But by the 50's the image of women in the future was back to staying at home, taking care of the kids, being a housewife. How lucky a lot has changed in the real future that is now.
Thanks Peter & Matt for the very interesting session, next time take a full hour :-)

To finish off some networking, and of course a nice goodie bag. Clo & her team always succeed in getting us nice stuff! This time we had Jacques chocolates for a fondue and some fun stuff.

See you next time.

 


Visual Studio 2008 extensions for WSS 3.0 v1.2 and other resources

Last week during TechEd Orlando, the new version of the Visual Studio extensions for Windows SharePoint Services 3.0 were announced: it’s now finally here, a version compatible with Visual Studio 2008. This version brings the same functionalities as v1.1 for Visual Studio 2005, among others:

  • Full Debugging with Microsoft Office SharePoint Server
  • Support for C# and VB.NET
  • Templates for Web Part, Team Site, List Definition, Field Control, Content Type, Event Handler and more.
  • Web Solution Package (WSP) Editor
  • Solution Generator creates Site Definition projects from an existing site

Check out my Resources page for the download link.

Now that I’m doing this post, it’s worth mentioning the latest additions to my SharePoint Resources page:

  • SharePoint 2007 Shared Services Provider User Profile Importer
  • SharePoint Content Deployment Wizard - http://www.codeplex.com/SPDeploymentWizard
    This tool by Chris O'Brien helps you export sites, lists, etc using .cmp files (Content Migration Package).
  • WSS3 Workflow Designers
  • SmartPart for SharePoint
    The SharePoint web part which can host any ASP.NET web user control. Create your web parts without writing code! – Now with support for ASP.NET Ajax.
  • STSDEV
    STSDEV is a proof-of-concept utility application which demonstrates how to generate Visual Studio project files and solution files to facilitate the development and deployment of templates and components for the SharePoint 2007 platform.
  • SharePoint SUSHI (that’s a cool name as I love sushi!)
    SUSHI is a powerful, user-friendly SharePoint application enabling you to accomplish common SharePoint administrative and development tasks. You can think of SUSHI as a Swiss army knife for SharePoint.
  • SharePoint SmartTemplates for Visual Studio
    Another project by Jan Tielens, already famous with the creation of the SmartPart (see above).

 

Technorati tags: , , , ,

 


MIX essentials Belgium on April 24th 2008

[Cross-posted from my MSDN blog]

Coming April 24th we are organizing our first edition of MIX essentials: this is a local 1 day event bringing you the latest information from the MIX08 conference held in Las Vegas early March.

Join the conversation and explore how you can create next-generation Web experiences. With Keynote presentations from Steve Ballmer, and other international speakers, unveiling the latest Web-oriented solutions from Microsoft.

Inspiration. Conversation. Education.
Now, the Belgian Web Team brings you MIX essentials, distilled to it's essence, a comprehensive program and an intimate opportunity for innovative, technical, creative and business strategists to engage Microsoft and each other in a conversation about the future of the web.

  • Explore the latest wave of opportunities and help redefine the boundaries between: content and commerce, PC and TV, Windows and the Web.
  • Experience global and local implementations of Silverlight and engage with key players in web development and design.
  • Witness the latest Beta of Silverlight 2 in action and get the latest on Blending it together using the Microsoft Expression tools
  • Learn how to cross the chasm of challenges that developers and designers typically face.
  • Be Inspired by the wide range of topics and one-on-one guidance from Microsoft Evangelists and the local web industry
  • Network with peers from your industry and exchange ideas that will change the Web Now

Register for The Next Web Now!
A unique chance to connect on a wide range of topics for one-on-one guidance and inspiration.

 image
Steve Ballmer, Chief Executive Officer of Microsoft Corporation
Steven A. Ballmer is Chief Executive Officer of Microsoft Corporation, the world's leading manufacturer of software for personal and business computing. Ballmer joined Microsoft in 1980 and was the first business manager hired by Bill Gates. Since then, Ballmer's leadership and passion have become hallmarks of his tenure at the company.
During the past 20 years, Ballmer has headed several Microsoft divisions, including operations, operating systems development, and sales and support. In July 1998, he was promoted to President, a role that gave him day-to-day responsibility for running Microsoft. He was named CEO in January 2000, assuming full management responsibility for the company, which includes delivering on the company's mission of enabling people and businesses throughout the world to realize their full potential.

Technorati tags: , ,

Final release of VSeWSS 1.1 is out

Good news comes to us from the Office Developers Conference: version 1.1 of VSeWSS (Visual Studio Extensions for Windows SharePoint Services) has been released.

Several new features have been added:

  • Solution Package Editing (renaming Features, reordering Features and more)
  • Visual Basic support
  • New item templates (List Instance, List Event Handler)
  • Bug fixes:
    • No more GUIDs in Feature Names
    • Support complex project names, e.g. with periods.
    • Can deploy assemblies to the bin folder, instead of GAC

See the complete list and download the tool over at the SharePoint Team Blog.
Also available now is a user guide to VSeWSS and what's coming with version 1.2.

 

Technorati tags: , ,

 


Silverlight project templates in Visual Studio 2008 – what is available and where to get them

Yesterday I was installing a new machine it was a bit confusing as where to get the right Visual Studio project templates for Silverlight version 1.0 and the alpha 1.1 version (now renamed to Silverlight 2.0). I had them working on my hold machine but didn’t actually remember which one I had installed.
So here’s a little overview of the different available tools and templates.

Silverlight 1.0 SDK and project templates
You can get the Silverlight 1.0 SDK including a Visual Studio project template file at this location: http://www.microsoft.com/downloads/details.aspx?FamilyId=FB7900DB-4380-4B0F-BB95-0BAEC714EE17&displaylang=en
The SDK offers the option to install a “Silverligh Javscript Application” project template in Visual Studio.
Unfortunately the Visual Studio project template included with the SDK won’t install on the VS 2008 RTM version, only VS 2005. However, a workaround for installing the project template “Silverlight Javascript Application” with Visual Studio 2008 can be found here:
http://adoguy.com/2007/09/02/Installing_Silverlight_1_0_Templates_on_
Visual_Studio_2008_Beta_2_(Orcas).aspx

Silverlight 1.1 (renamed to 2.0) project templates
Silverlight project templates for Visual Studio can be found in the "Microsoft Silverlight 1.1 Tools Alpha for Visual Studio 2008" download. Templates included with this download are: 

- Web site template: Silverlight Script Web. This template can be used to create Silverlight 1.0 Javascript web site.
sl_scriptweb
- Silverlight Project (in Visual Basic or C#): this is the template to
sl_vstemplate_project
- Silverlight Class Library template: this one can be used to create Silverlight client assemblies.

In addition to the project templates the Tools download also installs intellisense and code generators for XAML, debugging of Silverlight applications, integration with Expression Blend.

Note that you might hit a "…\TestPage.html.js access denied" error if you are using AVG anti-virus as I was. There is a comment on Scott Guthrie’s blog that explains how to fix this.

 

 


Happy New Year: from my rabbit

Two weeks ago I received a cool gadget from my colleagues at LBi: a nabaztag :-)
OK, I’ll admit it: I’m a bit geeky so I really loved the gift!

It was not a smooth thing to get it working because of wireless configuration settings. According to the information on the site a wireless security setting to WPA does not work. However after loading a new firmware and changing a default address setting as I found on the forum it’s now alive!

And let me take this opportunity to wish happy holidays to all of you, and a prosperous and exciting New Year 2008.

I hope the next year will bring interesting new projects to you all.

 

 

Technorati tags:

This one’s for you LBi!

After almost 7 years of .NET projects at LBi I’m leaving for a new challenge at Microsoft! More on that later…

I would like to take the opportunity to thank all of my colleagues at LBi in Belgium (previously D.A.D – Digital Age Design). Since the start at LBi I was able to learn a lot and evolve in my technical skills. Working on CMS projects, custom extranet applications MOSS projects :-), interactions with the creative/design department, all part my very interesting path at LBi.

Thanks to my manager Arnaud. And a special mention to the .NET team at LBi: keep up the good work and motivation! You are a great team and I’ll miss you. Here’s one to remember.

.NET team at LBi 3

L-R: Olivier, Benjamin, Jérémy (the one from the other side of the force), Arnaud (the chef :-), Lieven, Thomas, me, Gauthier, Mathieu, Nicolas and Thomas.

 

Technorati tags: , ,

ASP.NET 3.5 Extensions CTP Preview (with ASP.NET MVC) released

As announced on Scott Guthrie’s blog, the ASP.NET MVC Framework preview has just been released as part ASP.NET 3.5 Extensions CTP Preview. You can now try out for yourself!

If you haven’t read on the new ASP.NET MVC Framework, this new release is Microsoft’s response to a demand for a built-in model-view-controller (MVC) based architecture in ASP.NET.
This does not mean all your ASP.NET applications now need to be developed based on this architecture but it does allow you to apply this architecture when needed/wanted.

Get started here:

  1. Download the ASP.NET 3.5 Extensions CTP Preview via Scott Guthrie’s site. BWT, there’s much more to the Extensions than only the MVC framework. Read all about it at the above link.
  2. Get yourself acquainted with the framework by reading Scott Guthrie’s article series:
  3. Checkout some other resources:

And now, let’s check it out!

 

 

Technorati tags: , ,

 


A few notes from TechEd Barcelona

In a full week of sessions at TechEd Developers 2007 in Barcelona, there is a lot of information to be assimilated, new contacts made and because of a professional change in the near future still very much a different TechEd.

 

Visual Studio 2008 and .NET 3.5 features
With a RTM release by the end of this month Visual Studio 2008 is finally there. There are so many new exciting features to the C# and VB.Net languages and new functionalities in the IDE.
There is a great demo project called Dinnernow.net that uses several of the new technologies like LINQ, ASP.NET Ajax Extensions, WCF, WF, Powershell, etc. I went to two TechEd sessions (presented by David Aiken and Matt Winkler) that gave an overview of the whole project and what I can say is this: check it out, it will really help you understand ways to use these new technologies and features.

LINQ: I got the chance to learn more about LINQ in two sessions at TechEd. The good news for SharePoint developers: there is already a LINQ to SharePoint implementation on the way which is part of my Resources for WSS and MOSS for some time now :-)
Bart De Smet currently has an alpha version available at codeplex. There is a small video interview with Bart about this feature on the TechEd site:
http://www.mseventseurope.com/teched/07/developers/news/Pages/day5.aspx. Scroll down to “LINQ to SharePoint Implementation” for the video.

Microsoft Search Server 2008
Microsoft is working on a new search server that is based for on the search feature found in MOSS 2007. Checkout Joris’ great post on this for more details. 
There is also an “Express” version of this server, the release candidate is available here: http://blogs.msdn.com/enterprisesearch/archive/2007/11/06/announcing-microsoft-search-server-2008-express.aspx

Let’s make Popfly mashups!
With social networking sites like Facebook becoming more and more popular with all kinds of users, I love playing around with Popfly.
The Popfly explorer beta is out for download by the way.


I also had the opportunity to talk to a lot of people about all kinds of subjects. The Belgian party on Wednesday was such a great opportunity. See you at a next event!

Check out some photos of the event:

 

 


Two questions for Spencer Harbar

Yesterday I had the chance to ask two quick questions to Spencer during TechEd:

What is your favorite WCM feature in MOSS?
Definitely Content Query Web Part: this is an extremely powerful feature that is largely underestimated. This web part is very efficient both in performance and very easy to customize its look without one line of code (compiled code that is, you still need some XSLT code).

How is your book on WCM together with Andrew Connell going?
It’s coming along very well, a bit slower than we had hoped. The first draft version has just been finished for a first review and people should be able to get it in the beginning of next year.

Thanks Spencer for the time!

 


TechEd Session on performance for Internet facing web sites in SharePoint 2007

I just went to my first session on SharePoint during this edition of TechEd: “Building a High Performance .com Site on Microsoft Office SharePoint Server 2007”.
Spencer Harbar brought us an informative overview of the top things to take into account in regards to performance in WCM SharePoint sites.

Here are some of my notes:

  • Performance considerations must be taken into account at the start of the project so that optimization is built into the project from the start.
  • Long running processes in web parts: make use of the asynchronous programming techniques to run processes in parallel.
  • Accessing the object model:
    - always call .Dispose() on SPSite and SPWeb. These are actually managed wrappers to unmanaged code. The .Net garbage collector does not automatically release these objects in a timely fashion.
    - use the using()statement. This statement automatically calls the .Dispose() method for you.
  • When accessing collections via a property of an object, make a local variable to hold the collection and then access the local object. This going much faster, up to 25% performance increase.
  • Use the Content Query Web Part CQWP): it’s optimized and uses internal caching of queries that no custom web part can achieve, by far.
  • Use output caching in MOSS: this is not active by default but is a great increase in performance and can very easily be activated via the site settings interface.
  • Loading of core files (core.js mainly): this added a runtime by SharePoint but is often not useful for pure front-end WCM sites. There is a workaround to delay load the core.js file so that the rest of the page gets sent to the client and loaded first.
  • When creating WCM sites do not use the default WCM publishing site and those master pages as the basis. These contain a lot of embedded tables that do not load fast. Create a clean master page and CSS files, taking advantage of CSS2 features for example (that’s my own addition here).

That’s a quick list of things to take into account. Spencer will probably post on this on his website so do check out at http://harbar.net


BTW, check out Joris’ blog post about the keynote at TechEd. Some interesting announcements were made there.

 


 


TechEd Europe is just a few days away

Microsoft TechEd Developers 2007 is almost there! Starting next Monday 5th November 2007 in Barcelona.

I'm looking forward to this big event, there are so many interesting sessions I don't know which one to choose for most of the time slots.

Check out the agenda at: http://www.mseventseurope.com/OnlinePub/Public/sessions.aspx?EventId=HbLEvtKcPE4%3d
There are a few sessions on SharePoint from Ted Patisson, Patrick Tisseghem and Spencer Harbar. Spencer is one of my SharePoint heroes :-) I'll certainly go to his session.
And of course there are tons of sessions on Visual Studio 2008, LINQ, .NET 3.5, Silverlight and so much more.
So many sessions... so little time...

This year I will certainly do a few posts on sessions I'll attend and some general information about the event.

See you in Barcelona!

 

Technorati tags:

MOSS and SharePoint Services v3 resources page – latest additions

I have been updating my “Resources and tools for WSS 3 and MOSS 2007” page regularly over the last months. Here is a overview of the latest changes.

Additions to the list:

ElBlanco's SharePoint Add-ons
A collection of add-ons for WSS 3.0 and MOSS 2007, although at this time there is only one available: the useful Event Receivers Manager.

Useful Sharepoint Designer Custom Workflow Activities
This CodePlex project provides custom workflow activities for SharePoint Designer.

LINQ to SharePoint
Bart De Smet is working on a tool for using LINQ with SharePoint.

U2UPropertyPagePackage - a feature that adds a List settings page
If you ever needed to get all the details on a list including the ID, properties, content types, site column IDs, and more this feature is for you.

Application Pool Recycle Utility for SharePoint Developers
System Tray utility shows you all the application pools for your IIS and allows you to recycle them via the click of a button.

Updates to resources:

SharePoint Solution Installer: the source code for this tool has now been released via CodePlex.

Windows SharePoint Services 3.0 Tools: Visual Studio 2005 Extensions, Version 1.1 CTP – link added.

And not to forget the updated and revised versions of the WSS3 and MOSS 2007 SDKs:
SharePoint Server 2007 SDK: Software Development Kit
Windows SharePoint Services 3.0: Software Development Kit (SDK)

 

Technorati tags: ,

VISUG session on Silverlight

Yesterday I went to the Belgian VISUG session on Silverlight: “Light up the web: Visug goes Silverlight”.

Gill Cleeren presented a very good overview of the main parts of Silverlight 1.0 and 1.1, did enough demo’s and a small introduction on XAML. Great stuff to get started on this new technology!
You can find the source code samples on his Gill’s blog post: http://www.codeflakes.net/blog/post/Silverlight-presentation-slide-deck-and-demo's.aspx

Also check out Gill’s company blog to which he also participates: N-Technologies.

 

Technorati tags: , ,

My session notes on IT-Talks - Installing, administering and working with SharePoint 2007

Yesterday was a day at school. Not actually school but a full day at the IT-Talks user group session “Installing, administering and working with SharePoint 2007”.

It was a one hour drive from where I live, and it was on a Saturday, but there I went. A one-hour drive here in Belgium means I’m almost on the other side of the country :-)
Upon arrival at the location most people were already there so I had to search for a free spot. We were about 25 people assisting to the session, that’s not bad if I may say so.

The idea was to go over a few slides and do all the labs ourselves. However there were some infrastructure problems and the labs weren’t possible. So we mainly watched over on the projector.

The session was presented by Tom Vandaele and Bart Bultink.

Here are a few notes I made during the event, some of them are tips given by Tom, and some I write here as well more as a note for myself:

Installation of MOSS and domain accounts permissions
More a note for myself, but the basic permissions you need when installing MOSS 2007 are:

  • The SharePoint service account (farm account): needs to be a domain user and needs to be added on the SQL server with ‘dbcreator’ and ‘securityadmin’ permissions settings. Nothing more. Tip: also checkout Spencer Harbar's post on this.
  • The SharePoint seach account: needs to be a domain account, nothing more. Extra permissions to the database will be given to this account by the setup program itself.
  • The user account with which you log on to install must be a local Administrator’s member on the server. I guess this one is rather obvious.

Forcing the creation of a new database for each site collection
There is no setting that allows you to say “force creation of new database per site collection”, however there is a very simple way to enforce this. In Central Administration you can set the state of a database to Offline. This does not mean the database itself is stopped or inaccessible, just that it may no longer be used for a new site collection. By setting your databases to offline you force the Administrator to create a new database for each new Site Collection.
Note: just leave one database online for creation of mysites.
Also check out Tom’s post on this. 

Active directory profile import
A good base design of your AD OU structure is very important. For example you cannot import several organization units from a single AD.
Make sure your system accounts are on a separate OU that does not get imported otherwise those accounts will also end up in the search results. And you don’t want that to happen.

Backup/restore
There are two options available for backup/restore of SharePoint sites: SQL Server database backup and WSS backup functionality. None of these do a backup of your custom code so make sure all your custom solution files, web.config changes and the like are also backed up via the hard drive.
SQL database backup: very efficient backup, this is especially a good solution for backup/restore if you store each site collection in a separate database.
WSS backup/restore: takes more time and therefore probably less efficient than SQL database backup. This can be used to transfer a site collection from a staging environment to another.
Using import/export
This is not a backup functionality but may be somewhat linked: using the export/import functionality you can import a site collection as a sub-site of another site collection. This can be a helper if you need to restructure your site content.

Thanks to the organizers!

 

 


WSS3 and MOSS 2007 issue “The Web site wants to run the following add-on: 'Name ActiveX Control'” and how this affected the page load time

During the pre-production version of a public WCM site we were experiencing some strange delay problems with the loading of the first page visited on the site. The MOSS site is configured with dual authentication providers and anonymous access.
When viewing the first request in a session we sometimes had a wait of 20 to 30 seconds (!), the page would load until the body tag, begin loading the CSS and the background would show. After that we had to wait until the rest of the page loaded.
It was really the page loading until background color appeared, then the 20 second wait until the rest of the page was loaded.
My first though was there was something wrong with connectivity to the server but then we were having the same speed problem when requesting the page on the server locally.
We also did some stress testing to see page response times and the results were rather good as well. No server load problem either then.

Some of the test users were also mentioning a problem with an ActiveX control message “The Web site wants to run the following add-on: 'Name ActiveX Control”.

We decided to apply the workaround/solution proposed by the Microsoft KB article 931509: Message in the Information bar in Internet Explorer 7 when you browse to a Windows SharePoint Services 3.0 site or to a SharePoint Server 2007 site: "The Web site wants to run the following add-on: 'Name ActiveX Control'"

Cause of the problem is the Name ActiveX control (Name.dll) that is called by a SharePoint JavaScript file named “init.js”, has not been added to the list of preapproved controls in Internet Explorer 7. The Name ActiveX control is included in the 2007 Microsoft Office system.

There are two workarounds that require changes on the client computer: not a solution for an internet public site.
The third workaround is to adapt a JavaScript file so that the ActivX contol does not get loaded or called anymore. This is the only acceptable workaround for me.

Implementing the workaround

Even if you are using a custom master page chances are you kept the call to the init.js file as this:

<SharePoint:ScriptLink language="javascript" name="init.js" runat="server"/>

This server call generates a <script> tag on the page that fetches the init.js from the locale folder. The ini.js file can be found on the 12 hive, normally “C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033” for a US English version. If you installed a different language or use language packs then replace the 1033 by your locale. Also remember to apply the change to all language packs.

The change that we need to do in this init.js file is simply put the line that makes the ActiveX call in comment. Open up the init.js file (make sure to keep a backup both of the original and your version), locate the following section (it’s the last function in the file):

function ProcessDefaultOnLoad(onLoadFunctionNames)
{
 ProcessPNGImages();
 UpdateAccessibilityUI();
 ProcessImn();
 for (var i=0; i < onLoadFunctionNames.length; i++)
 {
  var expr="if(typeof("+onLoadFunctionNames[i]+")=='function'){"+onLoadFunctionNames[i]+"();}";
  eval(expr);
 }
 if (typeof(_spUseDefaultFocus)!="undefined")
  DefaultFocus();
}

Put the ProcessImn() function call in comment:

function ProcessDefaultOnLoad(onLoadFunctionNames)
{
 ProcessPNGImages();
 UpdateAccessibilityUI();
 //ProcessImn();
//rest of function

This is not exactly the proposed workaround by the KB article but I don’t really get their approach of just putting the function declaration in comment. I don’t even think that will work correctly since the function call still exists and will probably give a JavaScript error (or maybe I’m just missing something there). Anyway, IMHO putting the function call itself in comment is more effective.
I should mention also that creating the new initNoPresence.js file and using that instead of the ini.js in the master page did not have effect. I did not look further into that and just applied the change to the init.js itself.

What’s the result?

In our case applying this change to the init.js file has eliminated the page loading speed problem in IE7. And even with IE6 we see a big difference in loading time of the page.
So be sure to apply this change if you have a public internet site, a small change that can make a difference.

 

Technorati tags: , , ,

 

 


IT-Talks session on SharePoint 2007 Administration

Cross-posted from Joris' blog - guess some extra publicity can never hurt.

The Belgian user group IT-Talks is hosting a session titled "Installing, administering and working with SharePoint 2007" on 8th of September 2007.
Having a more developer focused knowledge on SharePoint server 2007 I think this session will be very interesting to get to know more about the installation part.

It's on a Saturday but anyway, see you there!

 


Custom Web Part: creating and deploying an ASP.NET 2.0 web part with a custom EditorPart for SharePoint 2007 and WSS3

In this post I’ll create a sample ASP.NET 2.0 web part with a custom EditorPart. Source code is available at the bottom of this post.
If you developed SharePoint 2003 (and WSS2) web parts you might know the functionality as ToolParts and the toolpart pane. There is an article on MSDN on how to create your custom ToolPart () by using the WSS2 web part base class. Although you can still use this when developing SharePoint 2007 or WSS3 web parts it is generally recommended to use the ASP.NET 2.0 base class.
The good news is when you build an ASP.NET 2.0 web part you can use it within or without SharePoint.

What does this sample contain? The web part displays a banner image and line of text. The banner URL and a choice of a month is done via the custom web part editor.
I’m deploying the web part assembly to the bin directory (not the GAC) and setting custom CAS security, all that put together in a SharePoint solution.
The web part itself is therefore usable in any ASP.NET project but the deployment part of this post is specific to MOSS and WSS3.

Creating the Visual Studio 2005 project
To develop custom web part(s) create a new class library project. Configure the namespace and assembly name in the solution properties window.
I normally delete the default class1.cs file and create any needed files from scratch.
Open the AssemblyInfo.cs file and add the following code at the end of the file:

[assembly: System.Security.AllowPartiallyTrustedCallers()]

We need to add this attribute because the assembly will be deployed to the local bin directory and give partial trust.

Adding properties to the editor pane via attributes
By using attributes on public properties of the web part you can have editable properties (in personal or shared mode). This can be achieved by adding the following properties to a public property:

[WebBrowsable(true)]

Personalizable(PersonalizationScope.Shared)]

public string BannerUrl

{

  get { return _bannerUrl; }

  set { _bannerUrl = value; }

}

This will automatically add any strings as textboxes in the toolpart pane, in the section Miscellaneous.
You can use these attributes for simple properties where you don’t require validation. String and int will automatically show a TextBox control. Enums will show in the form of a dropdown list.

Sample of how properties are automatically rendered in edit mode:

webpart_edit_properties

Implementing CreateChildControls and RenderContents
In my sample I’m overriding the CreateChildControls method to create constituent controls and then RenderContents method to render them to the page. There is some HTML being written to the page, you may want something fancier than a table so this is just a simple example.

protected override void CreateChildControls()

        {

            base.CreateChildControls();

 

            imageBanner = new Image();

            labelMonth = new Label();

            labelError = new Label();

 

            if (string.IsNullOrEmpty(_bannerUrl) || _month == 0)

            {

                labelError.Text = Properties.Resources.webpart_configuration;

            }

            else

            {

                imageBanner.ImageUrl = _bannerUrl;

                DateTime month = new DateTime(DateTime.Now.Year, _month, 1);

                labelMonth.Text = string.Format(Properties.Resources.editor_monthlabel, month.ToString("MMMM"));

                labelMonth.Font.Bold = true;

                labelMonth.Font.Size = FontUnit.XLarge;

            }

 

            //set ChildControlsCreated to true so that ASP.NET does not call method twice

            this.ChildControlsCreated = true;

        }

 

        protected override void RenderContents(System.Web.UI.HtmlTextWriter writer)

        {

            if (string.IsNullOrEmpty(labelError.Text))

            {

                writer.Write("<table border=1><tr><td>");

                imageBanner.RenderControl(writer);

                writer.WriteLine("</td></tr>");

                writer.WriteLine("<tr><td");

                labelMonth.RenderControl(writer);

                writer.WriteLine("</td></tr></table>");

 

            }

            else {

                labelError.RenderControl(writer);

            }

 

            this.EnsureChildControls();

        }

Adding a resource file
As this web part may be implemented in a different language at a later stage I normally add a resources file for any text used in the control.
Go to Project properties in Visual Studio 2005 and click the Resources item in the left. Click on the text to create a new resource file.

webpart_resources

Any strings used in the control can now be entered here. Accessing the strings in the file can be done like this:

this.Title = Properties.Resources.editor_title; 

This is best the approach when building the web part to be available in multiple languages. Always create a base resources file “Resources.resx” and then add needed languages in the following format: Resources.[language]-[COUNTRY].resx (Resources.en-US.resx, Resources.nl-NL.resx).

Creating the EditorPart class
By creating a custom EditorPart you can choose if you want to show checkboxes, dropdowns, textboxes or other types of controls. You may also add validation for required fields.

Add a new class to the project, in my sample: BannerEditorPart.cs

This control inherits from the base class System.Web.UI.WebControls.WebParts.EditorPart.
Implement the constructor:

public class BannerEditorPart : System.Web.UI.WebControls.WebParts.EditorPart

    {

        public BannerEditorPart()

        {

            this.ID = "BannerEditor";

            this.Title = "Banner properties";

        }

 

    } 

Note: be sure to set the ID property of the EditorPart. Although this does not seem to be a required property in ASP.NET, it will return an error when going to edit mode in a SharePoint web.

Override CreateChildControls() and RenderContents() as in the web part. Two extra methods are overriden in order to save changes to the properties.

public override void SyncChanges()

        {

 

            EnsureChildControls();

            BannerWebpart editorPart = WebPartToEdit as BannerWebpart;

            if (editorPart != null)

            {

                textImageUrl.Text = editorPart.BannerUrl;

                if (editorPart.Month != 0)

                {

                    dropdownMonth.SelectedValue = editorPart.Month.ToString();

                }

            }

        }

 

        public override bool ApplyChanges()

        {

 

            EnsureChildControls();

            BannerWebpart editorPart = WebPartToEdit as BannerWebpart;

            if (editorPart != null)

            {

                try

                {

                    editorPart.BannerUrl = textImageUrl.Text;

                    editorPart.Month = Convert.ToInt32(dropdownMonth.SelectedValue);

                }

                catch (System.Exception exc)

                {

                    _displayErrorMessage = true;

                    error = "Error: " + exc.Message;

                    return false;

                }

            }

            return true;

        }

Final step is to implement the IWebEditable interface on the web part BannerWebpart class and implement the CreateEditorParts method and the WebBrowsableObject property.

object IWebEditable.WebBrowsableObject

        {

            get { return this; }

        }

 

        EditorPartCollection IWebEditable.CreateEditorParts()

        {

            if (this.WebPartManager.Personalization.Scope == PersonalizationScope.Shared)

            {

                List<EditorPart> customEditorPartCollection = new List<EditorPart>();

                customEditorPartCollection.Add(new Demo.Webparts.BannerEditorPart());

                EditorPartCollection editorPartCollection = new EditorPartCollection(customEditorPartCollection);

                return editorPartCollection;

            }

            else

            {

                return null;

            }

        }

Building the manifest.xml and SharePoint solution (.wsp)

Strong name the assembly: go to Project Properties > Signing > Sign the assembly.

The SharePoint solution will install the web part using a .webpart file. In this file we need to add the public token of the assembly. To get the public key use you can use Reflector (see Resources).
XML for the BannerWebpart.webpart file:

<?xml version="1.0" encoding="utf-8" ?>

<webParts>

      <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">

            <metaData>

                  <type name="Demo.Webparts.BannerWebpart, Demo.Webparts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=bc0f0ce76789c794" />

                  <importErrorMessage>Cannot import web part.</importErrorMessage>

            </metaData>

            <data>

                  <properties>

                        <property name="Title" type="string">Demo web part - banner</property>

                        <property name="Description" type="string">

                              This is a demo web part

                        </property>

                        <property name="ChromeType">None</property>