Tools to develope with Sharepoint and WebParts
- OfficeServerSDK.exe
- Windows SharePoint Services 3.0 Tools – Visual Studio 2005 Extensions.exe
- Windows SharePoint 3.0 Services
- dotnetfx3setup.exe
- ReturnOfSmartPartv1_3.zip
- MS VisualStudio 2008 or 2008
Create a problem list
Site Actions > Create > Task
It is categorized under the Lists section.
Pros / Cons
- Using SmartPart: you can work with normal UserControl, refresh the file .ascx or .ascx.cs at runtime and see the results.
- Using WebParts you can debug your code, but on the machine where sharepoint is installed.
Installation notes
Save the files of the UserControl into the directory UserControls usually in C:\Inetpub\wwwroot\wss\VirtualDirectories\80\UserControls, but it depends by your sharepoint installation.
Read the content of a list
SPWeb myweb = SPControl.GetContextWeb(Context);
SPList products = myweb.Lists["Products"];
foreach (SPListItem product in products.Items)
{
// work with items like product["Name"], product["Total"]
// ..
}
Write into a list
void ListInsertion(string listName, object[] parameters)
{
// get the shartepoint context
SPWeb myweb = SPControl.GetContextWeb(Context);
// get the list reference
SPList items = myweb.Lists[listName];
// insert objects
if (parameters != null)
{
SPListItem newItem = items.Items.Add();
for (int i = 0; i < parameters.Length; i += 2)
{
string key = "" + parameters[i];
string value = "" + parameters[i + 1];
// list item creation
newItem[key] = value;
}
newItem.Update();
}
}
Inspect the field content
private string GetFieldDescription(SPListItem item)
{
// analyze all the fields of a single item
StringBuilder sb = new StringBuilder();
foreach (SPField field in item.Fields)
{
string line = string.Format("title: {0}, description: {1}, related: {2}, value: {3}
"
,field.Title
, field.Description
, field.RelatedField
, item[field.Title]);
sb.Append(line);
}
return sb.ToString();
}