When wanting to programmatically hide a WebPart, don’t try to set it’s Visible property to False. This will cause you lots of trouble and create errrors. The correct method is to set its Hidden property to True.
if (items.Count == 0)
this.Hidden = true;
These design solutions were created as part of the University’s move from a 10 year old, bespoke, Classic ASP driven Intranet (which I originally developed) to Microsoft SharePoint 2010. Their purpose was to act as a starting point for discussion among staff and students and to generate feedback.
There seems to be no built-in function or property to quickly return the correct URL for a SharePoint list item. The obvious property, SPListItem.URL, always returns an invalid URL along the lines of http://sharepoint/Lists/MyList/155_.000. Not ideal.
To get around this and return a correctly formatted web address, you can use the following code:
This is a useful little tip. By default, AM and PM time designators are output in uppercase (in the 1033 language set atleast) but there are times (in this case, enforced by a coporate style guide) when they should be lowercase. There are two ways to achieve this – one is…
DateTime now = DateTime.Now;
String nowString = now.ToString("dddd, d MMMM yyyy a\\t h.mm");
nowString = nowString + now.ToString("tt").ToLower();
… which is okay if you’re just using it the once. More than once, you’re better off using a DateTimeFormatInfo to set the AM and PM designators. Like so…