In this post I will show you how easy it is to develop webparts in MOSS (Sharepoint), If you know how to develop in .Net then it will be a breeze. It will be as easy as 13 steps so here we go.
Step 1
Create a new Class Library Project and name it any way you want I named mine as MyWebPart
Step 2
You now add a reference to System.Web as you are using the following namespaces
using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts;
You can do that by right clicking on the project and choose add a reference, choose the .Net tab
Do you coding now. Here is a sample code on how to render controls on the webpart
namespace MyWebPart { public class NewWebPart : WebPart { protected override void CreateChildControls() { TextBox myTextBox = new TextBox(); myTextBox.Text = "This is easy"; Controls.Add(myTextBox); } public override void RenderControl(HtmlTextWriter writer) { RenderChildren(writer); } } }
On this sample its just a simple rendering of a TextBox called myTextBox and assigning a value to the textbox. Once done you are ready to publish the code to your MOSS
Step 3
Determine the bin folder of your MOSS site, you can find it in IIS. Usually its in C:InetpubwwwrootwssVirtualDirectories{your MOSS instance name}bin
Step 4
Once found, copy and put that in your output path in the build properties of your project, also choose All configurations on the Configuration Section, so when you debug it publishes on your MOSS bin folder (not a best practice but we just doing it for simplicity if this walkthrough)
Step 5
Build the project and you will now see the dll on the MOSS bin folder
Step 6
Add a SafeControl Assembly on the web.config of your MOSS instance. That would be one directory above the bin folder.
Step 7
Now that your webpart is on the server you need MOSS to import the library you created for you, you can do that by going to Site Settings and Modify Site Settings
Step 8
Now go to Galleries and choose Web Parts
Step 9
Add the WebPart by clicking New
Step 10
Choose the webpart you just developed by ticking the checkbox beside it and click Populate Gallery
Step 11
Now your new webpart is available for use in any of you pages and it is now included in the library
Step 12
Now you can use it in any pages, if you add a new webpart it will be on the list
Step 13
Now you can use it. its that simple!’