Friday, April 24, 2009


The other day i discovered SPUtility, while browsing i found out some nice methods, check them out :-)

·         SPUtility.SendEmail(web, false, false, "", 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.

// 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);



No comments: