.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Forum >> SharePoint >> Post New QuestionBookmark and Share Subscribe to Forum

display UsageData in sharepoint using javascript?

Posted By: Sagar Pardeshi     Posted Date: March 01, 2011    Points:2   Category :SharePoint
plz help using client side code i have to try to display UsageData report using web plz suggest me which web i will use .

Author: Sunil Yadav       [Moderator]      
Posted Date: March 10, 2011     Points: 20   


You can use can use ECMA Script object modal to get site usage info using javascript.

Create a visual webpart or application page and add the below code in it.

<script type="text/ecmascript" language="ecmascript">

var usageInfo;
var site;
var clientContext;
function GetUsageInfo() {
this.clientContext = new SP.ClientContext.get_current();
if (this.clientContext != undefined && this.clientContext != null) {
this.site = clientContext.get_site();
this.clientContext.load(this.site, 'Usage');
this.clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));

function onQuerySucceeded() {
this.usageInfo = this.site.get_usage();
var info = 'Storage: ' + this.usageInfo.get_storage() + '\nStorage percentage: ' + this.usageInfo.get_storagePercentageUsed() + '\nVisits: ' + this.usageInfo.get_visits();

function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());

<input id="btnGetUsageInfo" type="button" value="GetUsageInfo" onclick="GetUsageInfo()" />

Hope this helps.

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend