Wednesday, March 23, 2011

SharePoint 2010: SP.UI.ModalDialog.showModalDialog not ready

I'm building a custom component which displays "ads". It needs to check a list to see if the current user has seen the ad. If they haven't then display a SharePoint 2010 modal dialog.

What I did (Javascript):
_spBodyOnLoadFunctionNames.push("OpenMyAd");

What was needed:
ExecuteOrDelayUntilScriptLoaded(OpenMyAd, "sp.ui.dialog.js");

Which does exactly what it says on the tin... It waits until the script is loaded and then executes what I told it to.

Credit goes to Sing Chan and his post.

Tuesday, December 14, 2010

SharePoint 2010: Getting all site collection tags

For those trying to figure out how to get the list of all tags out of SharePoint 2010 here ya go:

//Add these using tags at the top of your class.
using Microsoft.Office.Server.SocialData;
using Microsoft.Office.Server.UserProfiles;
using Microsoft.SharePoint.Portal.WebControls;

//This is the code neccessary to pull out all tags for 
//the current site collection.
SPSite site = SPContext.Current.Site;
SPServiceContext context = SPServiceContext.GetContext(site);
UserProfileManager upm = new UserProfileManager(context);
UserProfile up = upm.GetUserProfile(false);
SocialTagManager stm = new SocialTagManager(context);
SocialTerm[] terms = stm.GetAllTerms();

Friday, December 3, 2010

SharePoint 2010: Silverlight Media Player

What can you do with the Out Of the Box (OOB) SharePoint 2010 Silverlight Media Player?

Well you can add it to the page.
Provide buttons to Pause, Play and Stop.

But they (Microsoft) haven't provided us with any player states. Is the media player playing a movie or has it stopped?

In my current project I need to do something once the movie has finished. Unfortunately after looking through the Silverlight code (after decompilation). I can see that there are no events to plug into.

Here are the relevent bits:
// Methods
public string CaptureCurrentFrame();
public void Pause();
public void Play();
public void Stop();

// Properties
public bool AutoPlay { get; set; }
public string DisplayMode { get; set; }
public string Duration { get; }
public long DurationMilliseconds { get; }
public string EmbedText { get; }
public bool Loop { get; set; }
public string MediaSource { get; set; }
public string MediaTitle { get; set; }
public int NaturalVideoHeight { get; }
public int NaturalVideoWidth { get; }
public string Position { get; set; }
public long PositionMilliseconds { get; set; }
public string PreviewImageSource { get; set; }
public string TemplateSource { get; set; }
public double Volume { get; set; }

What I'll try to do is to re-skin the player and perhaps do a little magic. If I have any success in this area I'll create a post.

In the mean time. This is a good article to see what you can do with this control: http://msdn.microsoft.com/en-us/library/ee558890.aspx

Monday, November 29, 2010

SharePoint 2010: BDC doesn't work with SQL 2000

I'm at a client site. They have data on a SQL 2000 DB. We want to expose this to SharePoint 2010. Sounds like a simple task of creating BDC connection. Great!

But no. Apparently there isn't support for SQL 2000 in SharePoint 2010 BDC.

Humph...

The discussion on the MSDN forum. (Look at the bottom).

Also worth a look at this article, specifically the comments: MSDN Article

Friday, November 26, 2010

Blog move

Hi everyone,
Just a quick note that I have moved my blog from http://soreeyesdotnet.blogspot.com/ to http://sharepointchan.blogspot.com/

All posts have been copied across and I will be keeping the old blog around in case anyone has links pointing to my posts.

Regards,
Chan

Monday, November 22, 2010

Colour coding text in Blog posts

I found this great site: http://www.hilite.me/

It will generate html for you so your code can be displayed in all it's colourful glory.

Loving it!

SharePoint 2010: Web Part Properties

Even though I've made SP2010 web parts before for some reason I couldn't find any good articles on how to add Custom Properties to a web part.

So here is my take on a Custom SharePoint 2010 Web Part Property:
private string _targetSite = "SomeSite";
[Personalizable(PersonalizationScope.Shared),
WebBrowsable(true),
WebDisplayName("Target Site"),
WebDescription("Specify a site."),
Category("Configuration")]
public string TargetSite
{
get { return _targetSite; }
set { _targetSite = value; }
}

Oh and make sure you have the permissions to change settings.