Archive for the 'MOSS 2010' category

Cumulus Tag Cloud for SharePoint

Aug 31 2010 Published by Shoban under Downloads, MOSS 2010, Webpart

In this article we will see how we can develop a Tag Cloud WebPart for SharePoint Blogs. I have named this WebPart Cumulus Tag Cloud because this Tag Cloud is inspired from one of the most popular Tag Cloud for WordPress called WP Cumulus.

We will not be going into basics about how to develop a WebPart. If you are new to Visual Studio 2010 WebPart development, check my previous post Twitter Trends Webpart for SharePoint.

Below is a screenshot of how our TagCloud will look like in a SharePoint Blog.

Let’s get started!

As a First Step goto WP Cumulus Tag Cloud homepage and download the PHP plugin and unzip the files to a folder. We will be needing the tagcloud.swf file for our webpart.  Open Visual Studio 2010 and Create a new Visual Web.

Add tagcloud.swf to the Layouts Folder and by this time your Solution explorer should look like this

Open VisualWebpart1.cs and change


[ToolboxItemAttribute(false)] to [ToolboxItemAttribute(true)]

Add the below code which will add all necessary Texboxes for our custom WebPart properties.


//Color of the Tags
public static string tagsURL = "";
[WebBrowsable(true), Category("Cumulus Tag Cloud"), Personalizable(PersonalizationScope.User), WebDisplayName("Tags URL"), WebDescription("Enter the URL for the list which contains the Tags.")]
public string CumulusTagCloudURL
{
get { return tagsURL; }
set {
//Validate the URL
using (SPSite listSite = new SPSite(value))
{
if (listSite == null)
{
throw new Microsoft.SharePoint.WebPartPages.WebPartPageUserException("Unable to Locate the site");
}

using (SPWeb ListWeb = listSite.OpenWeb())
{
if (ListWeb == null)
{
throw new Microsoft.SharePoint.WebPartPages.WebPartPageUserException("Unable to open Web");
}

SPList CategoriesList = ListWeb.GetList(value);
if (CategoriesList == null)
{
throw new Microsoft.SharePoint.WebPartPages.WebPartPageUserException("Unable to find List");
}
}
}

tagsURL = value; }
}

//Flash Height
public static int flashHeight = 200;
[WebBrowsable(true), Category("Cumulus Tag Cloud"), Personalizable(PersonalizationScope.User),WebDisplayName("Height"), WebDescription("Height of the Flash Tag Cloud")]
public int CumulusTagCloudHeight
{
get { return flashHeight; }
set { flashHeight = value; }
}

//Flash Width
public static int flashWidth  = 260;
[WebBrowsable(true), Category("Cumulus Tag Cloud"), Personalizable(PersonalizationScope.User),  WebDisplayName("Width"), WebDescription("Widhth of the Tag CLoud")]
public int CumulusTagCloudWidth
{
get { return flashWidth; }
set { flashWidth = value; }
}

//Color of the Tags
public static string tagColor = "ffffff";
[WebBrowsable(true), Category("Cumulus Tag Cloud"), Personalizable(PersonalizationScope.User),  WebDisplayName("Color of the Tags"), WebDescription("These should be 6 character hex color values without the # prefix (000000 for black, ffffff for white)")]
public string CumulusTagCloudColor
{
get { return tagColor; }
set { tagColor = value; }
}

//Highlight color of the Tags
public static string tagHColor = "000000";
[WebBrowsable(true), Category("Cumulus Tag Cloud"), Personalizable(PersonalizationScope.User), WebDisplayName("Highlight color of the Tags"), WebDescription("These should be 6 character hex color values without the # prefix (000000 for black, ffffff for white)")]
public string CumulusTagCloudHColor
{
get { return tagHColor; }
set { tagHColor = value; }
}

//Background Color
public static string backgroundColor = "333333";
[WebBrowsable(true), Category("Cumulus Tag Cloud"), Personalizable(PersonalizationScope.User),  WebDisplayName("Background Color"), WebDescription("6 character hex color value")]
public string CumulusTagCloudBackColor
{
get {  return backgroundColor; }
set { backgroundColor = value; }
}

//Rotation Speed
public static int rotationSpeed = 100;
[WebBrowsable(true), Category("Cumulus Tag Cloud"), Personalizable(PersonalizationScope.User), WebDisplayName("Rotation speed"), WebDescription("Speed (percentage, default is 100)")]
public int CumulusTagCloudRotationSpeed
{
get { return rotationSpeed; }
set { rotationSpeed = value; }
}

And this is how WebPart properties page look like

Open the code behind file of your user control and add the following code


string listURL = VisualWebPart1.tagsURL;
string tagColor = VisualWebPart1.tagColor;
string tagHColor = VisualWebPart1.tagHColor;
string backgroundColor = VisualWebPart1.backgroundColor;
int rotationSpeed = VisualWebPart1.rotationSpeed;
int height = VisualWebPart1.flashHeight;
int width = VisualWebPart1.flashWidth;

if (listURL == "")
{
lblMessage.Text = "Edit your WebPart Properties to start using Cumulus Tag Cloud";
return;
}

TagCloud.InnerHtml = "<embed allowscriptaccess='always' bgcolor='" + backgroundColor + "' id='tagcloudflash' height='" + height +"' width='" + width + "' flashvars=\"tcolor=0x" + tagColor + "&tcolor2=0x333333&hicolor=0x" + tagHColor + "&tspeed=" + rotationSpeed   + "&distr=true&mode=tags&tagcloud=<tags>";

using (SPSite listSite = new SPSite(listURL))
{
if (listSite == null)
{
throw new SPException("Unable to Locate the site");
}

using (SPWeb ListWeb = listSite.OpenWeb())
{
if (ListWeb == null)
{
throw new SPException("Unable to open Web");
}

SPList CategoriesList = ListWeb.GetList(listURL);
if (CategoriesList == null)
{
throw new SPException("Unable to find List");
}
else
{

SPListItemCollection categories = CategoriesList.GetItems();

foreach (SPListItem category in categories)
{
TagCloud.InnerHtml = TagCloud.InnerHtml + "<a href='" + listURL + "?CategoryId=" + category.ID + "' class='tag-link-3' title='1+topic' style='font-size:8pt'>" + category.Title + "</a>";

}

}

}

}

TagCloud.InnerHtml = TagCloud.InnerHtml + "</tags>\" quality='high' src='/_layouts/Cumulus Tag Cloud/tagcloud.swf' type='application/x-shockwave-flash'>";

Add the below code to your user control


<div id="TagCloud" runat="server"></div>
<asp:Label ID="lblMessage" runat="server" Text="Label"></asp:Label>

That’s it.

You can download the WSP file or the Source from the codeplex homepage of Cumulus Tag Cloud

One response so far

SharePoint 2010 Service Manager

Aug 11 2010 Published by Shoban under MOSS 2010

The SharePoint Service manager let’s you start and stop all the SharePoint 2010 services on your workstation.

This is useful if you are running SharePoint 2010 on Windows 7 (or may be Vista) and don’t want SharePoint to slow your machine down when it’s not really needed.

Visit http://sharepointserviceman.codeplex.com/ to know more about SharePoint 2010 Service Manager.

One response so far

Twitter Trends Webpart [Silverlight Version]

Jul 30 2010 Published by Shoban under MOSS 2010

Last week we saw how we can create a Twitter Trends Webpart for SharePoint 2010. Jhonny has developed a Silverlight version of this webpart. He will be posting how he developed the webpart. For the time being enjoy the Twitter Webpart in his blog ;-)

2 responses so far

Twitter Trends Webpart for SharePoint

Jul 25 2010 Published by Shoban under Downloads, MOSS 2010, Webpart

In this article we will see how we can develop a Twitter Web Part for Sharepoint. We are going to use jQuery and Twitter Search API along with our favorite c# code. The Web Part will be a simple Twitter Widget which will display latest tweets for a Hashtag. Below is a screenshot of how our Web Part will look like.

We are going to name our Web Part Twitter Trends ;-) Lets get started

Fireup Visual Studio 2010 (Oh Yeah we will be using Visual Studio 2010 for our project and you will notice how easy it is for developers to build and deploy SharePoint Projects in VS 2010) and Select File -> New Project and create a new Visual Web Part Project.


Click OK and you will see another Window which will ask you to enter the Local SharePoint site which we will use to Debug our Web Part. Enter your Test Site and Click Finish.

Instead of designing our widget we are going to use the design of a Twitter Widget Tutorial in Tutorialzine.

We will be making few changes in CSS to suit our needs. Please check the above link to learn how the Widget is designed. We will not be discussing what changes were made to the CSS files also download the source code as we will be using CSS Files, Images and Javascript files from that project.

Back to our project in Visual Studio, Right Click our Project and Click Add -> SharePoint “Layouts” Mapped folder.

If you notice, Visual Studio automatically added a folder for us under layouts folder to store our files. Now Create 3 new folders namely CSS, Images, Scripts. Add CSS Files, Images and JS files to these folders.

Now your solution explorer should look like this

Open the ASCX file and add the following code


<link rel="Stylesheet" type="text/css" href="/_layouts/TwitterTrends/css/demo.css" />
<link rel="Stylesheet" type="text/css" href="/_layouts/TwitterTrends/css/jScrollPane.css" />
<script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="/_layouts/TwitterTrends/scripts/jquery.mousewheel.js" type="text/javascript"></script>

<script src="/_layouts/TwitterTrends/scripts/jScrollPane-1.2.3.min.js" type="text/javascript" ></script>

In the above code we have just referenced the proper CSS files and Javascript files including the jQuery file from Microsoft CDN.

Add the below code below the above lines of code. The code is self-explanatory also I have added comments so that it will be easy to understand.

<script language="javascript" type="text/javascript">
$(document).ready(function () {
$('#twitter-ticker').slideDown('slow'); //Slide down the Widget when the page has loaded
RefreshTweets(); //Function which does all the job
setTimeout("RefreshTweets()",60000); //Refresh the Tweets every 1 minute
});

function RefreshTweets() {
var container = $('#tweet-container');
if(hashtag == "") //Global variable declared through C# code
{
hashtag = "SharePoint"; //Set Default Hashtag
}
$.getJSON("http://search.twitter.com/search.json?q=%23" + hashtag + "&rpp=15&&callback=?", function (msg) {
container.html(''); //Remove the Loading GIF
for (i = 0; i < msg.results.length; i++) { //Build DIVs containing Tweets and add it to Container DIV
var str = '<div><div><a href="http://twitter.com/' + msg.results[i].from_user + '" target="_blank"><img src="' + msg.results[i].profile_image_url + '" alt="' + msg.results[i].from_user + '"/></a></div>';
str += '<div><a href="http://twitter.com/' + msg.results[i].from_user + '"target="_blank">' + msg.results[i].from_user + '</a></div>';
str += '<div>' + relativeTime(msg.results[i].created_at) + '</div>';
str += '<div>' + formatTwitString(msg.results[i].text) + '</div>';
container.append(str);
}

});
container.jScrollPane(); //Add Scrollbar

}

We will also be using 2 functions which is used to Format Tweet and Time (you can find this function in script.js which you have downloaded from Tutorialzine website)

function formatTwitString(str)
{
str=' '+str;
str = str.replace(/((ftp|https?):\/\/([-\w\.]+)+(:\d+)?(\/([\w/_\.]*(\?\S+)?)?)?)/gm,'<a href="$1" target="_blank">$1</a>');
str = str.replace(/([^\w])\@([\w\-]+)/gm,'$1@<a href="http://twitter.com/$2" target="_blank">$2</a>');
str = str.replace(/([^\w])\#([\w\-]+)/gm,'$1<a href="http://twitter.com/search?q=%23$2" target="_blank">#$2</a>');
return str;
}

function relativeTime(pastTime)
{
var origStamp = Date.parse(pastTime);
var curDate = new Date();
var currentStamp = curDate.getTime();

var difference = parseInt((currentStamp - origStamp)/1000);

if(difference < 0) return false;

if(difference <= 5)                return "Just now";
if(difference <= 20)            return "Seconds ago";
if(difference <= 60)            return "A minute ago";
if(difference < 3600)            return parseInt(difference/60)+" minutes ago";
if(difference <= 1.5*3600)         return "One hour ago";
if(difference < 23.5*3600)        return Math.round(difference/3600)+" hours ago";
if(difference < 1.5*24*3600)    return "One day ago";

var dateArr = pastTime.split(' ');
return dateArr[4].replace(/\:\d+$/,'')+' '+dateArr[2]+' '+dateArr[1]+(dateArr[3]!=curDate.getFullYear()?' '+dateArr[3]:'');
}
</script>

Next, Add the below code which will add the required DIVs and containers


<div id="main">
<div id="twitter-ticker">
<div id="top-bar">
<div id="twitIcon"><img src="/_layouts/TwitterTrends/images/twitter_64.png" width="64" height="64" alt="Twitter"/></div>
<h2>Twitter Trends</h2>
</div>
<div id="tweet-container"><img id="loading" src="/_layouts/TwitterTrends/images/loading.gif" width="16" height="11" alt="Loading.." /></div>
<div id="scroll"></div>
</div>
</div>

Now it’s time to add our Custom Property to the Web Part so that users will be able to enter their own hashtag.

Open VisualWebpart1.cs and change


[ToolboxItemAttribute(false)] to [ToolboxItemAttribute(true)]

Add the below code which will add a Textbox under a custom category.


[WebBrowsable(true),
Category("Twitter Trends"),
Personalizable(PersonalizationScope.User),
DefaultValue(""),
WebDisplayName("Hash Tag"),
WebDescription("Please enter a hashtag")]

public string TwitterTrendsProperty
{
get { return HashTag; }
set { HashTag = value; }
}
public static string HashTag;

Next, Open the code behind file for the user control which will show the Tweets and add the below code under Page Load event.


string strHashTag;
strHashTag = VisualWebPart1.HashTag;
Response.Write("<input type='hidden' value='" + strHashTag + "' id='hashtag'/>");
ClientScriptManager cs = Page.ClientScript;
cs.RegisterClientScriptBlock(GetType(), "hashtag", "<script>var hashtag='" + strHashTag + "';</script>");

In the above code we declare a new Javascript variable and set its value based on the Value entered in our custom property “Hashtag”

That’s it! Now it’s time to test our Twitter Trends Web Part ;-) Right click the project and select Deploy. Yes it is that simple!

Wait for Visual Studio to deploy the solution. You should see the status in the status bar

To test our new Web Part, open the site and add the Web Part. You should find your webpart under “Custom” Category.

After adding the Web Part, Click “Edit Webpart” to enter your own hastag and see our new Twitter Web Part in action ;-)

Download : Twitter Trends [Source Code] Twitter Trends [WSP]

5 responses so far

SharePoint 2010 convert License type

Jun 30 2010 Published by Shoban under MOSS 2010

SharePoint 2010 is available in 2 versions namely Standard and Enterprise. If you have installed a standard version and want to convert to Enterprise features then you can simply change the license type by

  1. Opening Central Administration
  2. Entering the new License Key by Clicking Convert farm license type

Looks Simple.. But wait, Do you see the Textbox disabled? :)

There is another way to change License type from Standard CAL to Enterprise CAL.

  1. Open Central Administration
  2. Navigate to Upgrade and Migration
  3. Click “Enable Enterprise Features
  4. Enter your  Enterprise CAL key and Press OK
  5. Wait for few minutes and enjoy the Enterprise features of SharePoint 2010

Keep in mind there is no turning back here. Once you upgrade to Enterprise version you cannot switch back to Standard version.

No responses yet

Virtual Labs for SharePoint 2010

Jun 28 2010 Published by Shoban under MOSS 2010

Unlike other development technologies SharePoint development may be a costly affair. We need a Windows Server OS if we are developing for MOSS 2007.

Things are getting better with SharePoint 2010 and you can install MOSS 2010 in a Windows 7 pc and start developing apps but what if you don’t have a good build or required software?

Virtual labs for SharePoint 2010 are here.  You can test drive SharePoint 2010 without any instalation.

Virtual labs for Developers cover the following

  1. MSDN Virtual Lab: Client Object Model
  2. MSDN Virtual Lab: Customizing MySites
  3. MSDN Virtual Lab: Designing Lists and Schemas
  4. MSDN Virtual Lab: Developing a BCS External Content Type with Visual Studio 2010
  5. MSDN Virtual Lab: Developing a Sandboxed Solution with Web Parts
  6. MSDN Virtual Lab: Developing a Visual Web Part in Visual Studio 2010
  7. MSDN Virtual Lab: Developing Business Intelligence Applications
  8. MSDN Virtual Lab: Enterprise Content Management
  9. MSDN Virtual Lab: Getting Started with SharePoint 2010
  10. MSDN Virtual Lab: LINQ to SharePoint 2010
  11. MSDN Virtual Lab: SharePoint 2010 User Interface Advancements
  12. MSDN Virtual Lab: Visual Studio SharePoint Tools
  13. MSDN Virtual Lab: WorkflowMSDN Virtual Lab: Workflow

IT Pro labs are available in TechNet.

One response so far

New SharePoint Exams available from July

Jun 24 2010 Published by Shoban under MOSS 2010

New SharePoint 2010 Exams Available in July

Announcing the availability in July 2010 of four new SharePoint 2010 exams:

  1. 70-573:TS: Microsoft SharePoint 2010, Application Development
  2. 70-576: PRO: Designing and Developing Microsoft SharePoint 2010 Applications
  3. 70-667: TS: Microsoft SharePoint 2010, Configuring
  4. 70-668: PRO: Microsoft SharePoint 2010, Administrator

Source

No responses yet

Developing on SharePoint 2010

May 24 2010 Published by Shoban under MOSS 2010

MSDN has just published an online course for developers to learn about Developing for SharePoint 2010.

The course includes:

  • 10 modules introducing developers to SharePoint 2010
  • 55 short instructional and demonstration demos
  • Hands on labs that you can download or try online with MSDN Virtual Labs
  • Test your skills quiz’s
  • Code samples for each module

Check out the course materials here.

No responses yet

3 ways for adding new column in SharePoint list

May 12 2010 Published by Hojo Clement under MOSS 2007, MOSS 2010, PowerShell, Tips

In this post we will see 3 different methods for adding columns in SharePoint list or document library or discussion board.

using browser
Go to the list which you want to add column
On the page that displays the list, click list’s settings and create columns.
Type a name for the column, choose the column type and click OK.

using Object model


SPSite site = new SPSite(siteUrl);
SPWeb web = site.OpenWeb();

site.AllowUnsafeUpdates = true;
web.AllowUnsafeUpdates = true;

SPList list = web.Lists["mylist"];
SPFieldText fldName = (SPFieldText)list.Fields.CreateNewField(SPFieldType.Text.ToString(), "mycolumn");
fldName.Required = true;
fldName.MaxLength = 50;
list.Fields.Add(fldName);
list.Update();

site.AllowUnsafeUpdates = false;
web.AllowUnsafeUpdates = false;

using PowerShell


[system.reflection.assembly]::loadwithpartialname("microsoft.sharepoint")
$site= New-Object Microsoft.SharePoint.SPSite ("http://mysite")
$web=$site.OpenWeb()
$list=$web.Lists["mylist"]
$list.Fields.Add("mycolumn", "Text", 0)

No responses yet

Download SharePoint 2010 developer training kit

May 11 2010 Published by Shoban under MOSS 2010

Microsoft has recently released SharePoint 2010 Developer Training Kit, a guidance that provides developers with advanced guidance on how to develop for SharePoint.  Through PowerPoint decks, Hands-On Labs, Source Code, and Instructor-Led Videos, the developer kit walks you through an array of important developer topics including Developer Roadmap, Visual Studio tooling, Workflow, Business Connectivity Services, and much, much more.

You can download the Training kit here.

Source

No responses yet

Older posts »