Wednesday, April 8, 2009
Improve Sharepoint Site Performance using Blogcache
<BlobCache location="C:\blobCache" path="\.(gif|jpg|png|css|js)$" maxSize="10" enabled="false" />
In order to improve the performance of your site, the BlobCache should be enabled.
<BlobCache location="C:\blobCache" path="\.(gif|jpg|png|css|js)$" maxSize="10" enabled="true" />
The maxSize attribute is in GigaBytes, so make sure you have enough room at the location.
See this article for more information about other caching techniques: http://blogs.msdn.com/ecm/archive/2006/11/08/how-to-make-your-moss-2007-web-site-faster-with-caching.aspx
Store Metadata in Property Bag for SPWEB
Many Windows SharePoint Services objects expose property bags, including:
SPWeb
SPFolder
SPFile
SPListItem
You can create and remove properties in a property bag programmatically, and you can modify the values assigned to properties. After updating a property in a property bag, you must invoke the Update() method so that the property value is persisted in the site database.
The following example shows code for adding a property to the property bag of an SPWeb object. The code also shows how to iterate through the property bag to retrieve key names and values.
Visual C# Code Example
// Obtain a reference to the current Web
SPWeb list = SPControl.GetContextWeb(Context);
// Enable updates to be made to the SPWeb object
list .AllowUnsafeUpdates = true;
// Add a property and update the property bag
list .Properties.Add("Project", "Development");
list .Properties.Update();
// Disable updates for the SPWeb object
list .AllowUnsafeUpdates = false;
// Iterate through the properties in the property bag
for each(System.Collections.DictionaryEntry webProperty
in list .Properties)
{
this.Page.Response.Write(webProperty.Key.ToString()
+ " : "
+ webProperty.Value.ToString()
+ "
");
}
Once my metadata are added to my SPWeb properties, it's impossible to remove them.
Here is my code to delete :
site.Properties.Remove("mykey");
site.Properties.Update();
site.Update();
Tuesday, April 7, 2009
Bind List Items using SPDataSource using the object model
<%@ Register Tagprefix="SPwebControls" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<SPWebControls:SPDataSource runat="server" ID="dsPersonTitles" DataSourceMode="List"
SelectCommand="<Query><OrderBy><FieldRef Name='FirstName' /></OrderBy></Query>"
>
<SelectParameters>
<asp:Parameter Name="WebUrl" DefaultValue="{sitecollectionroot}" />
<asp:Parameter Name="ListName" DefaultValue="Employee" />
</SelectParameters>
</SPWebControls:SPDataSource>
<asp:DropDownList runat="server" ID="ddlPersonTitles" CssClass="title" DataSourceID="dsPersonTitles" DataTextField="FirstName" DataValueField="ID">
</asp:DropDownList>
Parameters
The SPDataSource Inherits from SPDataSourceView, basically a helper class for SPDataSourceView.
After a little Reflector-ing of SPDataSourceView I found these keys it is processing from from the parameter values collection.
- webid
- weburl
- rootfolder
- listid
- listname
- listitemguid
- listitemid
- folderid
- nextpagedata
- startrowindex
- maximumrows
Monday, March 30, 2009
SharePoint Object Model
* SPWeb (represents an individual site).
* SPSite (represents a site collection, which is a set of web sites).
* SPVirtualServer (represents a virtual server).
* SPGlobalAdmin (used for global administration settings).
In order to perform actions on data within a web, it is necessary to first get an SPWeb object (e.g. SPWeb MyWeb = SPControl.GetContextWeb(Context);)
The complete object model is grouped into lists, files (documents), security and administration:
* Lists - use these objects under the Microsoft.SharePoint namespace to view and edit data in SharePoint lists:
o SPList (basic list object for getting to list data).
o SPListCollection (collection of list objects).
o SPListItem (item/row in a list).
o SPListItemCollection (collection of list items).
o SPView (view of a SharePoint list).
o SPField (field/column in a list).
o SPListTemplate (template for a list).
* Files - use these objects under the Microsoft.SharePoint namespace to access document files in SharePoint sites:
o SPFile (file object).
o SPFileCollection (collection of files).
o SPFileVersion (version of a file).
o SPFolder (folder object).
o SPDocumentLibrary (document library object).
o SPDocDiscussion (discussions on a file).
o SPDocTemplate (used when creating a new file).
* Security - use these objects under the Microsoft.SharePoint namespace to edit access rights and security information:
o SPUser (user object).
o SPRole (site group object).
o SPGroup (cross-site group object).
o SPPermission (assigned permissions).
o SPRightsEnumeration (available permissions).
* Administration - use these objects under the Microsoft.SharePoint.Administration namespace to edit server-wide administrative settings.
o SPGlobalAdmin (top level administration object).
o SPVirtualServer (virtual Server object).
o SPQuota (storage/user quota limit object).
o SPGlobalConfig (configuration options).
o SPSiteCollection (collection of sites on a virtual server).
In terms of mapping the user interface onto the object model terminology:
* Site Collection = site.
* Site = web.
* Top-level site = rootweb.
* Subsite = subweb.
Friday, March 13, 2009
SharePoint Escape Characters
Ran into a problem when I was writing script to add a new entry to a column (using XML web services). I could not get the column names the same as the were name. Like my "e-mail" column. So for that one I had to type for the id in the script e_x002d_mail.
Blank space: _x0020_
Underscore: _x002d_
Dash: _x0027_
Here is the Format:
Char Code
[space] 20
< 3C
> 3E
# 23
% 25
{ 7B
} 7D
| 7C
\ 5C
^ 5E
~ 7E
[ 5B
] 5D
` 60
; 3B
/ 2F
? 3F
: 3A
@ 40
= 3D
& 26
$ 24
SharePoint Lists Filter Keywords and Expressions In Views
[Today] The current date.
[Me] Current User of the site.
[Modified] Date item was last modified.
Filter Expression Examples:
[Modified]+7 A week after the last modification.
DATE(YEAR(Modified),MONTH(Modified),DAY(Modified)+5) 5 Days after the last modification.
Formulas and Functions:
http://office.microsoft.com/en-us/sharepointtechnology/CH100650061033.aspx
Thursday, March 5, 2009
How to add sharepoint DateTime Control and People Picker in custom application page
The control is actually called a "PeopleEditor" and is in the 'Microsoft.SharePoint.WebControls' namespace. You will need to add a reference to 'Microsoft.Sharepoint.dll' to your project in Visual Studio, which is something you probably already have if you are writing anything that works with SharePoint.
First, we need to add a reference to the Namespace containing our control:
<%@ Register Tagprefix="wssawc" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" / %>
Next, add the PeopleEditor control to your page:
<wssawc:PeopleEditor
AllowEmpty="false"
ValidatorEnabled="true"
id="userPicker"
runat="server"
ShowCreateButtonInActiveDirectoryAccountCreationMode="true"
SelectionSet="User" / %>
Next, add an object on the server to work with the control:
public class MyPageName : Page
{
protected PeopleEditor userPicker;
…
}
{
….
PickerEntity pe = (PickerEntity)userPicker.Entities[0]; //gets first user in list
string username = pe.Description;
SPUser user=web.AllUser[username];
…
}
Notes:
The Description property will return the full account name (e.g. domain\username)
The DisplayText property will return the resolved name in the editor control (e.g. First Last)
Date Time Control :
You can create user control webpart for that and add this webpart to sharepoint environment othrewise you can get error like " object reference can not set".
Cheers it and enjoy.
