Append your own messages to the Developer Dashboard in SP 2010 using Javascript

This is a great idea – if you want to quickly be able to identify where part of a solution is failing, you can use JavaScript to write to the Developer Dashboard – John Powell from Microsoft has some great info on his blog –

The code he provides (duplicated below) allows you to “write” to the Dev Dashboard in the same way us Classic ASP developers used to write comments into the page to see what was going on (response.write, anyone?)

function DeveloperDashboardSection(sectionId, sectionTitle) { 
this.Title = sectionTitle; 
this.Id = sectionId; 
DeveloperDashboardSection.prototype = { 
Id: '', 
Title: '', 
DeveloperDashboardVisible: function() { 
EnsureSection: function() { 
var section = $('#'+ this.Id); 
if(!section.length) { 
var sectionHtml = "<table id='"+ this.Id + "' width='49%'><tbody><tr><th colspan='2'>"+ this.Title + "</th></tr></tbody></table>"; 
AddEntry: function(context, message) { 
if(!this.DeveloperDashboardVisible) return; 
var entryHtml = "<tr><td nowrap='nowrap'><span>"+ context + "</span></td><td nowrap='nowrap'><span>"+ message + "</span></td></tr>"; 
$('#'+ this.Id).append(entryHtml); 

To use the script, create an instance of the DeveloperDashboardSection and use the instance throughout your code to trace custom messages to the Dashboard:

var theSection = new DeveloperDashboardSection(‘sampleId’, ‘Custom Section’);
theSection.AddEntry(‘someMethod()’, ‘The method was called’);

The messages will appear on the Developer Dashboard in it’s own section:


When the Dashboard is not visible, the tracing calls are benign.



About Brad Saide

I'm a SharePoint consultant. I'm also slowly going bald, seem to have a permanent spare tyre around my waist and enjoy socialising with friends over a beer or 10. The last 2 may possibly be related. Started working with SharePoint when the first version was in limited beta release (participated in the Technology Adoption Program while at Woolworths) and have been committed to the adoption of the technology as a business enabler ever since.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s