Category Archives: Downloads

SharePoint document convertor

SharePoint Document Converter solution gives a start on how we can leverage the Word automation Service to convert documents to formats that word can support. This project convert documents of type “DOCX” or “DOC” to any possible file type that word support like to PDF, XPS, DOCX, DOCM, DOC, DOTX, DOTM, DOT, XML, RTF, MHT.

Check out more about the project in Codeplex Project Home Page.

CAML Viewer Web Part

One of the easier ways of creating CAML query is by creating the required view and then creating Query from it.

CAML Viewer makes it even more simpler. CAML Viewer lets you view CAML query for Views and it also shows internal names for all fields.

I developed this using SharePoint client object model and you can download the source code from here.

I am planning to add more features soon. If you have a suggestion or comment, please add it to the Discussion page.

Cumulus Tag Cloud for SharePoint

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

[sourcecode language="csharp"]

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

[/sourcecode]

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

[sourcecode language="csharp"]

//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; }
}

[/sourcecode]

And this is how WebPart properties page look like

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

[sourcecode language="csharp"]

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 = ““;

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 + “” + category.Title + ““;

}

}

}

}

TagCloud.InnerHtml = TagCloud.InnerHtml + “\” quality=’high’ src=’/_layouts/Cumulus Tag Cloud/tagcloud.swf’ type=’application/x-shockwave-flash’>”;

[/sourcecode]

Add the below code to your user control

[sourcecode language="csharp"]

[/sourcecode]

That’s it.

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

Twitter Trends Webpart for SharePoint

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

[sourcecode="JavaScript"]


[/sourcecode]

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.

[sourcecode="JavaScript"]

[/sourcecode]

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

[sourcecode="JavaScript"]

Twitter

Twitter Trends

Loading..

[/sourcecode]

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

[sourcecode language="csharp"]

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

[/sourcecode]

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

[sourcecode language="csharp"]

[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;

[/sourcecode]

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

[sourcecode language="csharp"]

string strHashTag;
strHashTag = VisualWebPart1.HashTag;
Response.Write("");
ClientScriptManager cs = Page.ClientScript;
cs.RegisterClientScriptBlock(GetType(), "hashtag", "");

[/sourcecode]

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]

Recent Posts Webpart [Download]

In this article we will see how we can develop a webpart which will display the latest posts from different blogs. This was easily achievable using a Content Query WebPart but there are few issues. one of them was the non availability of options like choosing blogs.

Only option available was to create a new custom WebPart. It was easy as I expected. you can scroll down to download the webpart.

Recent Posts Webpart

Recent posts WebPart Toolpane


Download WebPart | SourCode