07 October, 2008

MSN Live Control

So at the moment I've been playing around with the new Microsoft Live controls that have been released into the developers world. The problem is that it's so new that hardly anyone has done anything with them, and if they have they haven't done anything worthwhile. I've been having a go at adding these controls as a webpart.

To get started you need to in
stall:

1. The live controls.

To download these controls, go to the Windows Live Tools Web site,
http://dev.live.com/tool

Instructions on installing the controls as well as a list of any prerequisites for the
controls are listed on this site.

2.You also require SharePoint extensions in Visual Studio.


1. Create a new webpart:


1. File > New > Project
2. Select
SharePoint > Web Part
3. Name: MSNChatWebPart

4. Location: Your development folder e.g. D:\DE
V\
5. SolutionName: MSNChatWebPart

6. Make sure your screen looks like the following :



Then hit OK.


You should now have a new Web Part project.


2. Add a Reference
  1. Find the Microsoft.Live.ServerControls.dll
  2. copy this DLL into the D:\Dev\MSNChatWebPart\ MSNChatWebPart\bin folder and also into the GAK folder of the SharePoint project.
  3. Add a reference to the above DLL in your project. Use the DLL in your bin folder.
  4. In your WebPart1.cs file add the following using statement above the namespace
using Microsoft.Live.ServerControls;


3. Adding the Control

1. You will need to programmatically add the control to the Web Part.
2. This control can be configured to your liking. For now we are going to only some basic
configuration. A full list of options is available a http:/msdn.microsoft.com/en-us/library/cc305083.aspx




I will talk more about this in a future post

3. Just note that the PrivacyStatementURL is required in order for this control to work.
For now
you can create a default page named PrivacyPolicy.aspx You n
eed to add the following code
to your project
  1. protected override void CreateChildControls()
  2. {
  3. base.CreateChildControls();
  4. //create new instance of the MSNChatControl
  5. MessengerChat myessengerChat = new MessengerChat();
  6. //add privacy statement URL path here
  7. myMessengerChat.ProvacyStatementURL = "http://~.PrivacyPolicy.aspx";
  8. //give your control an ID
  9. myMessengerChat.ID = "myMessengerChat";
  10. //add this control to the controls collention of the webpart this.Controls.Add(myessengerChat);
  11. }
This will add the MSNChat control .

4. Build your solution
5. Make sure in your Project Properties under Debug the Start browser with URL is set to your SharePoint site path
6. Deploy the solution

4. Add the web part to your site


1. Go to the design view of your page.
2. Click Add a Web Part on any zone. In this example we will add in to the middle zone
3. Expand All WebParts > and select your WebPart1 Web Part>>Add




So there we have it a nice simple MSNChat webpart for your mySite.