SharePoint Web Part Code Snippets for VS 2005

When you want to develop web parts for SharePoint the “traditional” way, it’s good idea to use the Web Part Templates for Visual Studio .NET. These templates will give you a start class to quickly build web parts. Unfortunately these templates are not (yet?) available for Visual Studio 2005. Since Windows SharePoint Services SP2 you can run your WSS sites on .NET 2.0, so you can build your SharePoint web parts with Visual Studio 2005. Given that copy/pasting code is rather cumbersome I’ve create a couple of code snippets for Visual Studio 2005 that will generate code for a SharePoint Web Part. Currently I’ve got code snippets to create:

  • C# Web Part (shortcut wp)
  • C# Web Part Property (shortcut wpprop)
  • C# Tool Part (shortcut tp)

I’m still working on the other items (provider and consumer web part) and the VB.NET versions (any volunteers?). You can download them from the GotDotNet site (, the ZIP contains a VSI package so you can easily install them in VS 2005. (Make sure you select the code snippets you want to install, see screenshot)


  • Jan, Great files. How do you compile your webparts from vs 2005 to 1.1 framework? Do you use MSBuild?

  • You don't have to compile to .NET 1.1 if WSS is running on ASP.NET 2.0. Just create class lib. project, add references to System.Web and Microsoft.SharePoint.dll, and use the snippets. Then compile in VS2005 and deploy like you would do for 1.1 web parts.

  • Are there any examples of displaying an ASP.NET 2.0 web part in SharePoint using Son of SmartPart? I've found lots of examples of displaying user controls but none using the Son of SmarPart WP.

    Also, can Son of SmartPart display custom ASP.NET 2.0 web parts that inherit from the WebPart class (NOT SharePoint web parts created in Visual Studio 2005 and extending from the SharePoint dll)?


  • Great job man, this is really nice thanks :).

  • Greetings Jan & other esteemed Sharepoint WP Developers,

    Per usual, kudos to Jan for his snippets, and continued trailblazing for us.

    Say, does anyone know if it's possible to use VS.NET C# Express Edition 2005 to develop web parts for a .NET Framework 1.1 environment?

    My current engagement is for a very large corporation - the kind that take years to adopt a new change like .NET1.1 - to - .NET 2.0 upgrades. I'll be developing custom web parts for .NET1.1 for at least the next year - but I WANT to do it inside a new version of VS.NET C# Express Edition 2005 (because it's new & has a modest laptop install footprint).

    Does anyone know if this is even possible, or must I continue to use VS.NET 2003 EA Edition for developing .NET 1.1 - compatible web parts?

    Any info is most welcome.


    Mark Vogt.Sharepoint

  • I get an error message when installing that says String Cannot Have Zero Length. Any ideas?

    Also, did you ever have any takers on the version? The smart part spoiled me on using the designer for sharepoint web parts (it was wonderful), and now that i am designing them for wss v3, I can't find a good way to do this.

    Are you going to do a Smart Part for wss v3?

  • I have downloaded the snippet ..but don't know how to use it.Please Help..

  • Thanks to you my problem solved

  • Hi,

    i wanted to develop web parts in visual studio 2005.i am using web part manager for that.but when i run application i get error:-"localsql server was not registered"
    can anyone help me.
    thanks in advance

  • What do u do after downloading and installing these files
    how do i get the web part

  • im using VS.NET 2005 and WSS 3.0. What do i need to have to install Web Part Templates for VS.NET 2005 so that they can be used in WSS 3.0

  • Same question as Amar...
    but extended: I have VS on my machine and MOSS on my VM. I would like to create web parts for MOSS 2007 on my machine but I cannot install Visual Studio 2005 extensions for Windows SharePoint Services 3.0 on it because it is WinXP and WSS is not installed on it :(
    Any workarounds for this?

  • Great work, really nice

  • I have the same problem as Dragan. Im running windows XP with Visual Studio 2005, and M$ wont let me install the studio extensions because im not running windows server 2003. is it actually supposed to be this way ? a requirement to run windows server 2003 to be able to develop for sharepoint services ?

  • I'm kind of in shock that this download is not available for XP boxes. This appears to me to be a serious limitation. It seems Microsoft's recommendation is to set up a virtual machine with Windows Server 3.0 and WSS 3.0. This is a lot of time to spend to get a tool that's supposed to make life more convenient.

  • I downloaded the snippets and ran the install... the final installation window indicates that the Web Part and Tool Part were skipped... how come?

  • i got the same problem as Dragan.i could not able to install web part templates on my system(windows xp).plz let me know how to develop web parts using web part templates in vs 2005

  • i have download ad installed the code snippet.
    the problem is that i dont see it when i create a new project !
    can you please help me ?

  • same problem.......

    i have download ad installed the code snippet.

    the problem is that i dont see it when i create a new project !

    can you please help me ?


  • I was not able to download the zip file as GotDotNet site is being phrase out. Could you please re-post it to a place I can fetch? Thanks!

  • I was not able to download the zip file as GotDotNet site is being phased out or I could not figure out its location.
    Can you plz provide another location. Thanks!!!!!!!!!!

  • So are we just a$$ out since the GotDamnNet site is Tango Uniform?

    Does anyone care?

  • I care!
    But somehow I don't think this would work in my environment here, since my Visual Studio is on my XP desktop machine, and not on the SharePoint server machine. I believe that those people having problems with not being able to create a new WebPart project or whatever, I heard that to build WebParts you have to be using Visual Studio on the same machine that SharePoint server is on. Please correct me if I'm wrong... (I'd really like to be able to develop the WebParts on my XP box!!)

  • I am trying to use a web part to grab the credentials that a user has entered SharePoint with to pass them to a web page that accept FORM/POST login input. Any idea how I would do that?


Comments have been disabled for this content.