In WSS 3.0, the creation of web parts is
easier than ever. Since WSS 3.0 is fully
based on and built around ASP.Net 2.0 you can leverage the .net framework to do
your heavy lifting.
Today I thought I would create a simple post on how to
create your very first web part. If you
want a more in-depth how-to, please see the Links section below for more
information.
Getting Started:
-
Create a new VS 2005 project
- Reference the System.Web namespace in your
project
- Create a new class and have it inherit off of
WebPart
public class SimpleWebPart
: WebPart
- Override the Render class, add a add the following
line
writer.Write("Hello, my
first web part");
- Compile your web part.
- Copy your webpart to the bin directory on your
WSS web server found here on my server
C:\Inetpub\wwwroot\wss\VirtualDirectories\80\bin
- Open the web.config file to change the trust
level of the site to WSS_Medium
- Add your assembly to the SafeControl list (I would
copy an existing one and modify it)
NOTE *** If you have not signed your assembly you can remove the PublicKeyToken
attribute ***
- Open up a web browser and navigate to http://<<YourServerNameHere>>/_layouts/newdwp.aspx
If you made the correct settings to the Web.Config file you should see your
webpart in the list.
- Select your new web part and click Populate
Gallery. This will create the needed
config file for your webpart.
- Now go to your sharepoint site and add the new
web part.
- Open a WSS list in edit mode
- Click add web part
- Select your new web part and add it to the list.
12 Enjoy your new web part.
I know this is just the tip of the ice berg, but you have
got to start someplace.
Links
- More In-depth how-to - here
- Web Part Control Set Overview - here
- Creating web parts in WSS - here
Till next time,
Posted
08-13-2007 7:50 AM
by
Derik Whittaker