Geeks With Blogs

Tangible Thoughts SharePoint, MOSS? and all the other questions
[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


Crossposted from tariqayad.com

Posted on Thursday, October 15, 2009 12:00 PM SharePoint | Back to top


Comments on this post: Whats wrong with this code?

# re: Whats wrong with this code?
Requesting Gravatar...
nice sharing thanks.
Left by kenan on Jan 15, 2010 5:16 AM

# re: Whats wrong with this code?
Requesting Gravatar...
Hi,
Peter this side from Canada. What this is all about? Can someone clarify this to me?

Thanks
Peter
[url=http://www.candy.com/]Candies[/url]
Left by Peter on Apr 01, 2010 4:15 PM

Your comment:
 (will show your gravatar)


Copyright © Tariq | Powered by: GeeksWithBlogs.net