Oct 12, 2010

Getting the URL parameter in Javascript

Sample URL : http://mysite/sites/Demos/Training/PCM.aspx?ID=429

var paramID=GetValue('ID');

alert('Result ID '+paramID)

function GetValue(name)
{
   name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
   var regexS = "[\\?&]"+name+"=([^&#]*)";
   var regex = new RegExp( regexS );
   var results = regex.exec( unescape(window.location.href) );
   if( results == null )
     return "";
  else
    return results[1];
}

Oct 9, 2010

Developer Dashboard in Sharepoint 2010

What is Developer Dashboard ?

Developer dashboard in SharePoint gives developers the ability to monitor how well their code base is performing – on a page by page basis.

For instance – when enabled, at the bottom of every page you'll see a report of all the custom code that has ran on that page, as well as how long it took to run.

This becomes very valuable information especially when querying SharePoint content. You may have several web parts on one page all querying information from across your Farm, and the SharePoint developer dashboard helps you know how well each performs, which can help you identify if one is becoming a bottle neck for your whole page

The report shows the following information:

1. What controls loaded and how long each took to load

2. What specific database queries executed and the execution time of each

3. Events that were fired during the page load

4. Order of the page lifecycle and time during each stage

5. Requests with timings for each one.

6. Database queries and their response times.

7. Load times for each Web Part on the page and Pre-render time.

8.Number of Web server SPRequest(s) and their timing.

9. Any critical events.

There are two methods to initialize this tool to work on your sites. You can do this with your handy old stsadm.exe or with PowerShell.

Stsadm.exe (either set your path statement to read in the Bin Directory or navigate to c:\program files\common files\microsoft shared\web server extensions\14\bin)

Enter the following command
stsadm –o setproperty –pn developer-dashboard –pv OnDemand

In PowerShell

(Get-SPFarm).PerformanceMonitor.DeveloperDashboardLevel = "OnDemand"


The results will show you the following little icon on the top right corner of your page


Clicking on the icon circled with either display or hide the results. Scrolling down your page you will see the following results:



Ref links: http://www.spfoxhole.com/Blog/Lists/Posts/Post.aspx?ID=131