Saturday, January 26, 2008

RSS Reader webpart with tab support and asynchronous periodic data refresh using AJAX

I have recently written my first article on Codeproject.

The article describes the development of AJAX enabled webpart on MOSS 2007 SP1.

The cool thing about it is the that it also utilizes the AJAX Control Toolkit including programmatically adding and styling TabContainer and TabPanel controls which can be quite tricky for a beginner. The article can be found here:

Sunday, January 20, 2008

Get RSS Url for a list or Document Library Programmatically

Recently I developed an RSS Reader webpart which would take the RSS URL of list to render its feeds. Very much same like the out of the box webpart with the exception that it was AJAX enabled. I would post the details of that part on the blog when I am finished.

An idea came to me that wouldn’t it be nice to also enable users to just give the list URL rather than RSS URL since would reduce the few steps on the user’s side. I thought it would be just a matter of accessing the RssUrl property of SPList object, but to my surprise it was not to be. There is no property such property in the API, so I decided to write my own function for it.

Let’s analyze the RSS URL of a list or a library. Whenever the user clicks on View RSS feed on a library, here is how SharePoint constructs the URL:


Listfeed.aspx is the inbuilt RSS viewer of sharepoint which accepts a parameter which is the GUID of the list. %2D tokens refer to ‘-‘characters which exist inside the GUID. Considering all this, it’s easy to write a function which will return the RSS URL. Here is the code for the same:

private string MakeRssUrl(string rawurl)




Uri url = new Uri(rawurl, UriKind.Absolute);

if (url.GetLeftPart(UriPartial.Path).Contains(“_layouts/listfeed.aspx”))


return rawurl;




string rssurl;

using (SPWeb web = new SPSite(rawurl).OpenWeb())


SPList list = web.GetListFromUrl(rawurl);

rssurl = web.Url + "/_layouts/listfeed.aspx?list=" + list.ID;

return rssurl;




catch (UriFormatException e)


return string.Empty;



The code is pretty self explanatory. The argument to function is list URL or RSS url. We first check if the URL is RSS URL itself, and if it is we just return. Otherwise, if it’s a list URL, we create a SPList instance, grap the GUID and contatenate it with the site URL and listfeed.aspx.

Note that the function does not validate if the given URL was actually a valid list URL or not. The exception handling for that case should be left to the caller of the function.

Monday, January 14, 2008

Reveal Unknown Error on Sharepoint 2007 pages

How often you have encountered the infamous Unknown Error on Sharepoint 2007 pages. If you are a Sharepoint developer, chances are that innumerable times :)

However, if you are also seasoned ASP.NET developer as well, you also know the trick behind it to reveal them., which I am going to give it here.

The trick is that ASP.NET Framework wants to show the real error message, but its the sharepoint which abstracts the message from the user. This is good for production systems since those cryptic error message may not be user friendly. Or revealing those full stack trace could cause potential security concerns.

But for an experienced developer, this is almost must to turn them off. This is achieved by turning off custom errors in web.config

Find the web.config for the site you normally use as your development site. Locate this tag

<SafeMode ... CallStack="false" ...> and change it to CallStack="true"
Set <customErrors mode="On" /> to mode="Off"
Set <compilation batch="false" debug="false"> to <compilation batch="true" debug="true">

Now you will get the full stack trace as soon as the error is raised.

Sunday, January 06, 2008

Unknown Error on Manage Form Templates Page (Manageformtemplates.aspx)

Getting Unknown Error on this page?.

No helpful clue in Sharepoint log or Event Viewer?

This can happen if database record in the list of published InfoPath forms had a null where it shouldn't be.

Thanks to this blog, there is small code snippet given here which will delete the culprit entry.

But make sure that you run this script under the debugger and only execute the delete operation for the offending form, otherwise it will delete all the published forms in your farm.

Unable to Join the Game: Age on Kings (Conquerors)

This is a first off topic post on my blog about a lovely game from Microsoft: Age

of Kings also called as Age of Empires II : Conquerors. I have been a fan of this

game from my schooldays and been playing multiplayer matches on

during my college days. Lately Microsoft has closed However there

are few third party multiplayer sites going on which are exactly same as For ex:

However I was facing the famous issue Unable to Join the Game. Forwarded all

the required ports, turned of firewalls , still no issue. I even installed the

TCP sniffer to see if incoming packets were hitting my system. To my surprise

they were and still no luck in connection. Finally after 3 days of trying, I found a

hidden setting in my wireless router which was causing this issue. I had Upnp

enabled in my router by default and disabling it completely resolved the

issue. To anyone curious who want to know what the Upnp is : J