Tuesday, March 27, 2012

sharepoint get username javascript

Below is the code snippet to get the current login user name in web part or you can use Client object model..

var sLoginUserName ="";


if(document.getElementById('ctl00_LoginCtrl')!=null)
sLoginUserName =document.getElementById('ctl00_LoginCtrl').innerText;




sharepoint xml intellisense

While we are working with Sharepoint xml files like Feature.xml, Elements.xml or ONET.xml files we wont get any intellicense by default.

But for any developer it is hard to remember all these information. So, here is the easiest way to get the intellisence

1. Open your xml file in Visual studio.

2. Go to properties pane of the xml file and click on schema and browse for the file.

3. locate file named "wss.xsd" from C:/Program Files/Common Files/Microsoft Shared/web server extensions/12/TEMPLATE/XML/wss.xsd

Note : this file will have all the xml defined functions which is easily recognized by the visual studio.
















Then you will get the intellisece for the sharepoint solution..


Javascript code to get Query string value in sharepoint

var paramID=GetValue('ID');



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];
}