Microsoft.SharePoint.WebControls.DateTimeControl ignores regional settings

by Sven De Bont 28. November 2008 09:24

When you use an instance of the Microsoft.SharePoint.WebControls.DateTimeControl in SharePoint (for example in a webpart), the locale will always be set to en-US, even if the web of user have specified a different locale.

To overcome this, you need to explicitly set the LocaleId property of the control to the correct locale.

DateTimeControl dtCtrl =new DateTimeControl();
dtCtrl.ID = "dtCtrl";
dtCtrl.LocaleId = (int)SPContext.Current.RegionalSettings.LocaleId;
this.Controls.Add(dtCtrl);

You should use SPContext.Current.RegionalSettings as this reflects the RegionalSettings for the current user (they might differ from the Web if the user modified this).

Currently rated 4.0 by 1 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

SharePoint

Sharepoint lookup with picker

by Sven De Bont 19. November 2008 14:39

Microsoft Sharepoint Server 2007 lookup control with element picker for custom list.
This control is useful if you need to choose lookup data from large lists. This control supports single and multi select mode.

http://www.codeplex.com/lookupwithpicker

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

SharePoint

‘Title’ field and property not available on SPItem when using a View to access the SPListItemCollection

by Sven De Bont 16. November 2008 09:47

You can get an SPListItemCollection from a List using a View with the following code:

SPList list = SPContext.Current.Web.Lists["My List"];

SPListItemCollection items = list.GetItems(list.Views["All Items"]);

When then try to access the Title field of any of the individual SPListItem instances in the collection you will receive an ArgumentExecption

//all these statements will throw an Argument Exception
string titleField = item[0]["Title"];
string titleProperty = items[0].Title;
string titleValue = items[0].GetFormattedValue("Title");

As a workaround, you can access the Title field value using the LinkTitle field:

//this will return the correct value
string title = items[0].GetFormattedValue("LinkTitle");

Currently rated 2.0 by 1 people

  • Currently 2/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

SharePoint

Ajax Loader Icons Generator

by Sven De Bont 16. November 2008 09:29

The site http://www.ajaxload.info allows you to freely generate and download ajax loader images. You can choose style, foreground color and background color to create a wide variety of icons. You can also set the background color to ‘transparent’.

ajax-loader      ajax-loader2      ajax-loader3

http://www.ajaxload.info

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Utilities

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen