Wednesday, September 24, 2014

JSRequest

Today I was exploring JSRequest in sharepoint and I found it very useful for some of the most common things that we will be doing in SharePoint.

Some of the uses of JSRequest are:

1. Reading querystring values from the URL
2. Getting the file name of the page
3. Getting the path name of the file that is getting browsed

Before using the JSRequest properties, you need to call a method called "EnsureSetup" on JSRequest

JSRequest.EnsureSetup();

//Getting a querystring value called searchResults
var searchResults = JSRequest.QueryString["searchResults"]

//Get the current page name. i.e - "default.aspx"
var pageName = JSRequest.FileName;

//Get the current path name. i.e - "/sitecollectionurl/libraryname/default.aspx"
itemId = JSRequest.PathName;



Referred the following url's for the same

http://mahedevelopment.blogspot.com/2013/03/getting-query-string-values-using.html

http://praneethmoka.wordpress.com/2012/01/12/some-useful-javascript-variablesfunctions-in-sharepoint/


Its easy to use and easy to remember

No comments:

Post a Comment