Thursday, November 22, 2007

event handler

if you want to add a event handler for a site or web, you can't use feature to install the handler, you must use API to install it. for example, you want to overwrite the webdeleting event.

Tuesday, November 06, 2007

How to get SharePoint Central Administration webapplication URL?

Microsoft.SharePoint.Administration.SPAdministrationWebApplication.Local.Sites.VirtualServer.Url.ToString();

Monday, November 05, 2007

How to lock/unlock a site through 'post' method

We can easily lock/unlock a site through API from a console or windows application. By using the properties of SPSite, readlocked or writelocked. But have you tried to do it within a web application. There is a little tricky here.

You will receive error message "The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again" .

ok, then you can do some poke around on google, someone will tell you that should include below code in Page_Load event:

Context.Items[SPGlobalAdmin.RequestFromAdminPort] = true;
Page.RegisterHiddenField("__REQUESTDIGEST", ga.AdminFormDigest);

you also need to define 'ga' in your page cs file:
Microsoft.SharePoint.Administration.SPGlobalAdmin ga = new Microsoft.SharePoint.Administration.SPGlobalAdmin();

But , it still refuse to work!! That makes me crazy!

Finally, if you put your page under C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\ADMIN, a virtual directory under Sharepoint Central Administrator site. It works! The page is code-inline.

by the way, SPGlobalAdmin is obsolete now but I can't find the proper replacement regarding to its AdminformDigest property.

site template大小的限制

site template可以包含站点的内容。但是却有10mb大小的限制。用下面这个命令改成20mb。stsadm -o setproperty -pn max-template-document-size -pv 20000000这个东西其实我也没有试过,因为一开始想用site template, 后来发现用不着,但这个东西还是花了点时间在网上查到了。

有没有用过SPQuery?

This summary is not available. Please click here to view the post.