Whats wrong with this code?

Thursday, 15 October 2009 12:30 by tariq
[code]

/// <summary>
/// Gets or sets the site URL.
/// </summary>
/// <value>The site URL.</value>
[WebBrowsable(true),
WebDescription("Url of the site to process reports on"),
WebDisplayName("Site Url"),
Personalizable(PersonalizationScope.Shared)]
public string SiteUrl
{
    get
    {
        if (string.IsNullOrEmpty(siteUrl))
        {
            return SPContext.Current.Web.Url;
        }
        return siteUrl;
    }
    set
    {
        siteUrl = value;
    }
}


[/code]

The above code snippet looks like  a  reasonable WebPart Propperty. In-fact you will find nothing weird with it untill you provision this webpart through a feature.

What happens is the reference to the SPContext…. in the property messes up the WebPart Order on the page and moves the webpart to Order 1 (i.e. first webpart on the zone), no matter what other preference you would have set in your feature.

Interesting eh? Something to keep in mind for future

Tags:   , , ,
Categories:   sharepoint | wss
Actions:   E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed
Comments are closed