kamagra how much to take

Get Locale From SPWeb URL

So I was working today on a some code where I was passing in the URL as a parameter and needed to harvest the locale so that I could get the culture information, the WebPart was going to be involved with a geo-deployment. Here is the code to accomplish that:

  1. public static CultureInfo GetLocale(string url)
  2. {
  3. SPWeb web = GetWeb(url);
  4. CultureInfo locale = web.Locale;
  5. web.Close();
  6. web.Dispose();
  7. return locale;
  8. }

Notice that you should take into account of disposing of the relevant objects that you are using!

The helper method that you see in the above is just a static wrapper that is called when I want to return a SharePoint Web, as opposed to having to re-code it each time. I keep it in a generic class library.

  1. public static SPWeb GetWeb(string url)
  2. {
  3. SPSite site = new SPSite(url);
  4. return site.OpenWeb();
  5. }

Happy geo-developing (that should be a word).

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>