Found a very useful helper in codeplex: SPUtility.js
- Set or get field values
- Make a field read only
- Hide a field from view
- No server side code to deploy!
I found it very useful. Here is my own prefered way to do:
- I put my script in .txt files and upload to a configuration library.
- Then, I create a Content Editor Web Part in each of DispForm.aspx / EditForm.aspx / NewForm.aspx.
- In the CEWP settings, set the url of my script files.
By doing so, I do not need to go edit the page each time I need to edit the script. I can just go edit the script in the library. Multiple pages that use the same script also can benefit in such way.
Is quite common in code, we often need to reference to “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14” aka 14 Hive directory in SharePoint 2010. I guess SharePoint had included a smart and easy way to get the value instead of developers to hard-code it.
So, the answer is SPUtility.GetGenericSetupPath
This returns C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\
This returns C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\Images
This SharePoint Object Model actually available since MOSS 2007.