The other day i discovered SPUtility, while browsing i found out some nice methods, check them out :-)
· SPUtility.SendEmail(web, false, false, "someone@somewhere.com", subject, body);
· string featurePath =SPUtility.GetGenericSetupPath("template\\features");
// returns C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES
Redirect to the SharePoint Error Page.
This is a nice way of handling errors cleanly and consistently.
try
{
// some code that might fail
}
catch (SPException ex)
{
SPUtility.TransferToErrorPage("An error occurred.\n" + ex.Message);
}
4. Redirect to any page.
I find this really handy as you can provide flags that let you redirect relative to the layouts directory (if you have some custom layout pages)
// send user to login page
SPUtility.Redirect("login.aspx", SPRedirectFlags.RelativeToLayoutsPage,HttpContext.Current);
Original: http://www.trinkit.co.nz/blog/archive/2007/04/30/programming-in-wss-use-sputility.aspx
No comments:
Post a Comment