Blog Archive

Friday, August 10, 2012

Adding a Context Menu to Different Column in List View

There are situations in which List View Web Part in SharePoint 2010 is very handy. When we insert the SharePoint 2010 List View Web Part on the page then  by default it will add certain columns of the list. Normally Title column has Context Menu for the List Item but what if we want to have that context Menu on some different column and here is our solution.

We can have Context Menu on some different column in the List View Web part. We can do it by using the small change in the FieldRef column in the list view web part. Add ListItemMenu and LinkToItem Attributes to the desired Field and set the value as 'True' for them.


<FieldRef Name="Name" ListItemMenu="TRUE" LinkToItem="TRUE" />

Clearing the Cache using Code

I come across a situation where I have to perform the manual Sign Out of the SharePoint 2010 Site and the easiest way to do so is just clearing the cache using code.

Following Code will remove all the cache files from your computer and will clear all the browser cache and indirectly forcefully sign out from the SharePoint site. (As we are clearing the FedAuth Cookie and its information in the Cache.)


     public void ClearApplicationCache()
    {
        List<string> keys = new List<string>();

        // retrieve application Cache enumerator
        IDictionaryEnumerator enumerator = Cache.GetEnumerator();

        // copy all keys that currently exist in Cache
        while (enumerator.MoveNext())
        {
            keys.Add(enumerator.Key.ToString());
        }

        // delete every key from cache
        for (int i = 0; i < keys.Count; i++)
        {
            Cache.Remove(keys[i]);
        }
    }

Opening the Pop up page in SharePoint and refresh the parent after closing the Pop-up.


SharePoint 2010 has lot of out of box JavaScript functions but they are not directly open. One of it and very useful function is "OpenPopUpPage" and this function is very handy in the development of SharePoint.

This function will open the new page in the Pop up window (ModalDialogBox) and when that is closed then the parent page will get refreshed. This is very similar to add new item in the list.


<a onclick="OpenPopUpPage('http://SharePointPageLink', RefreshPage); return false;" href="">This will open the page in Pop up and will refresh the parent page when the Pop Up page is closed. < /a>