Integrating activity feed of a Facebook page in your SharePoint site

For the past couple of days one of my colleagues was trying to integrate the activity feed of our client’s Facebook brand page in the client’s public portal. When I was looking into it I initially tried with the Activity Feed plugin provided in the Facebook plugins page.

Our requirement was to load all the activities that are happening in our Facebook page such as comments, posts, videos, likes etc. But when I was using the activity feed plugin I realized that the activity feed plugin only brings the Facebook page activity done from the site in which it is currently hosted. For example, if you have integrated the activity feed plugin in your site, the plugin only shows the activity that is created from But our intentions was to bring the complete set of activities happening in the Facebook page.

Thankfully I found out the Facebook Like Box which met our requirements. It fetches the completely activity feed of a Facebook page and integrates into your site. You can also comment and like posts from the plugin.


ASP.NET DataGrid – Export to CSV encoding issue

If you are exporting an grid to the CSV format you might see some special characters appearing the exported file. This is because of not setting the right encoding format. I initially tried with UTF8, UTF32 and Unicode and none of them exported the data correctly. Finally I set the encoding to default like this –

Response.ContentEncoding = Encoding.Default;

Finally the single quotes and hypens were appearing correctly in the CSV. Please not that you have to HtmlDecode your data if you have already HtmlEncoded it.

Opening a SharePoint list item without the navigations in a page using ‘IsDlg’

When you are working with custom master pages with a customized left navigation (done with SP designer) you would have noticed that no matter how many times you set it as “Custom Master Page” and “Default Master Page” in designer the list forms in the site will open with its own left navigation. This is because the list forms will make use of the application master page which will be residing in the Layouts folder and not the default or custom master pages.

In one of my recent projects I had a mail notification feature for a list which will send a mail when a new item is added. The mail will be sent with a link to the item. So I build the URL as http://app/sites/site2/Lists/Invoices/Dispform.aspx?ID=5 which points to the item with the ID as 5 in the list Invoices.

But opening the link as such will show the list item with the old left navigation which we don’t want. So when I checked out the URL opened by SharePoint when “View item” is clicked in the ribbon I found that it opens with a query parameter IsDlg in the URL which mentions whether the item is opened in a dialog. But unfortunately when I tried the same parameter as IsDlg=1 in the link the item opened fine with the left navigation hidden but the scrollbars disabled. Arrgh. Now the SP madness begins. But before I plucked all my hair out I luckily found this brilliant answer by XueQi which mentions that we can either use IsDlg=0 or IsDlg=2 for the scrollbars to work fine.

And the expedition continues.

Filtering list items in SharePoint based on current user and current user groups

Of late, I was working on a list view where I’ve to filter the items based on the current user and the current user groups. Filtering the items by the current user is a straight forward approach where you can select the user field and set the value to [Me]. But there is no provision in the list view filter page where you can filter the items based on the group specified in the field.

But with the help of designer you can manually edit the CAML of the XSLT list viewer webpart in the view page and use the Membership element to filter based on the group. All you have to do is to use CurrentUserGroups as the membership type to show that particular item for the users in that specified group.

  <Membership Type=\"CurrentUserGroups\">
    <FieldRef Name=\"AssignedTo\"/>
    <FieldRef Name=\"AssignedTo\"></FieldRef>
    <Value Type=\"Integer\">

Let’s consider that an item has the filed value as “Kate, John; Approvers”. The item will be shown to the user John kate as well as the members of the group ‘Approvers’. Remember that you have to set the people or group field to allow multiple values as well as selecting objects from SharePoint groups to hold such a value.

Microsoft Community Contributor Award 2011

Okay, I’m surprised. I got a mail from Microsoft few hours ago stating that I’ve been awarded “Microsoft Community Contributor Award” for the year 2011. This is the mail (but not the complete one) I got.

Microsot Contributor Award

Dear Raghavendra,

Congratulations! We’re pleased to inform you that your contributions to Microsoft online technical communities have been recognized with the Microsoft Community Contributor Award.

The Microsoft Community Contributor Award is reserved for participants who have made notable contributions in Microsoft online community forums such as TechNet, MSDN and Answers. The value of these resources is greatly enhanced by participants like you, who voluntarily contribute your time and energy to improve the online community experience for others.

Thank you for your commitment to Microsoft online technical communities and congratulations again!

Thank you Microsoft for your recognition. Okay what else do I get apart from the certificate and the cool badges? They have given me 12 month free subscription for “Microsoft Press E-Reference Library” which have hundreds of books in different formats and the patterns and practices whitepapers etc. Cool!

Using Telerik RadWindow as a popup or confirm box

Telerik RadWindow is mostly used as an ajax popup window to load a separate page. But it can be used a neat alert/confirm box instead of using the JavaScript confirm box. Here is the code below –


<asp:Button ID="btnOpenPopup" runat="server" Text="Close" OnClick="btnOpenPopup_Click" />
<br />
<asp:Label ID="lblMessage" runat="server"></asp:Label>
<telerik:RadWindow ID="radwindowPopup" runat="server" VisibleOnPageLoad="false" Height="150px"
                    Width="300px" Modal="true" BackColor="#DADADA" VisibleStatusbar="false" Behaviors="None" Title="Unsaved changes pending">
    <div style="padding: 20px">
        Do you want to save the changes?
        <br /><br />
        <asp:Button ID="btnOk" runat="server" Text="Yes" Width="50px" OnClick="btnOk_Click" />
        <asp:Button ID="btnCancel" runat="server" Text="No" Width="50px" OnClick="btnCancel_Click" />


public partial class Default : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)

    protected void btnOpenPopup_Click(object sender, EventArgs e)
        radwindowPopup.VisibleOnPageLoad = true;

    protected void btnOk_Click(object sender, EventArgs e)
        radwindowPopup.VisibleOnPageLoad = false;
        lblMessage.Text = &quot;Changes are saved!&quot;;

    protected void btnCancel_Click(object sender, EventArgs e)
        radwindowPopup.VisibleOnPageLoad = false;
        lblMessage.Text = &quot;Changes are discarded!&quot;;

Button ‘btnOpenPopup’ opens the popup by making the radwindow visible by setting ‘VisibleOnPageLoad’ to true. To hide it you just need to set it back to false. You’ve got your custom confirm box now which looks sleek.

Using CommonShowModalDialog in SharePoint

I’ve not found any post explaining the usage of CommonShowModalDialog in SharePoint, the default popup used by SharePoint across the board. So I thought why can’t I make one.

The method exists in core.js and it is used OOTB by SharePoint for opening popups in places like selecting a web application from a list of web applications, selecting a site collection from a list of site collections etc. (you could see these in Central administration). So here is the method –

function openPopup(){
    commonShowModalDialog("/_layouts/selectitem.aspx", "resizable: no; status:no; scroll: no; help: no; center: yes; dialogwidth:410px; dialogHeight:300px;", RetrieveItemValue);

CommonShowModalDialog has similar parameters as a simple

  1. Target URL
  2. Window features
  3. Callback function

To pass a value from the popup to the parent page use window.returnValue in te popup to save the value before closing the window.

//called from the popup page
function closePoup(){
    window.returnValue = myValue;

Retrieve the value passed from the popup in the callback function mentioned.

//Retreives the value sent from the popup
function RetrieveItemValue(retValue) {

As simple as that.