Saturday, December 29, 2012

Form field date validation using javascript

<script language=”javascript” type=”text/javascript”>
function PreSaveAction()
var date1 = getTagFromIdentifierAndTitle(“INPUT”,”DateTimeFieldDate”,”Start Date”);
var date2 = getTagFromIdentifierAndTitle(“INPUT”,”DateTimeFieldDate”,”End Date”);
var arrDate1 = date1.value.split(“/”);
var useDate1 = new Date(arrDate1[2], arrDate1[1]-1, arrDate1[0]);
var arrDate2 = date2.value.split(“/”);
var useDate2 = new Date(arrDate2[2], arrDate2[1]-1, arrDate2[0]);
if(useDate1 > useDate2)
alert(“The End Date cannot happen earlier than the Start Date”);
return false; // Cancel the item save process
return true; // OK to proceed with the save item
function getTagFromIdentifierAndTitle(tagName, identifier, title) {
var len = identifier.length;
var tags = document.getElementsByTagName(tagName);
for (var i=0; i < tags.length; i++) {
var tempString = tags[i].id;
if (tags[i].title == title && (identifier == "" || tempString.indexOf(identifier) == tempString.length – len)) {
return tags[i];
return null;

Hiding a field in newform.aspx

<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">

Friday, December 14, 2012

To Lock or Unlock a site collection by using Central Administration


1. Verify that you have the following administrative credentials. 
      • You must be a member of the Site Collection Administrators group for the site collection.

2. In Central Administration, click Application Management.

3. On the Application Management page, in the Site Collections section, click Configure quotas and locks. The Site Collection Quotas and Locks page opens.

4. If you want to change the selected site collection, in the Site Collection section, on the Site Collection menu, click Change Site Collection. Use the Select Site Collection page to select a site collection.

5. On the Site Collection Quotas and Locks page, in the Site Lock Information section, select one of the following options:
     •Not locked: To unlock the site collection and make it available to users.
     •Adding content prevented: To prevent users from adding new content to the 
       sitecollection. Updates and deletions are still allowed.
     •Read-only (blocks additions, updates, and deletions)
       To prevent users from adding, updating, or deleting content.
     •No access: To prevent access to content completely. 
       Users who attempt to access the site receive an access-denied message.

6. If you select Adding content prevented, Read-only (blocks additions, updates, and deletions), or No access, type a reason for the lock in the Additional lock information box.

7. Click OK.


1.Verify that you meet the following minimum requirements: See Add-SPShellAdmin.

2.On the Start menu, click All Programs.

3.Click Microsoft SharePoint 2010 Products.

4.Click SharePoint 2010 Management Shell.

5.At the Windows PowerShell 2.0 command prompt, type the following command:
      Set-SPSite -Identity "<SiteCollection>" -LockState "<State>"

•<SiteCollection> is the URL of the site collection that you want to lock or unlock.
•<State> is one of the following values:
Unlock: To unlock the site collection and make it available to users.
NoAdditions: To prevent users from adding new content to the site collection. Updates and deletions are still allowed.
ReadOnly: To prevent users from adding, updating, or deleting content.
NoAccess: To prevent access to content completely. Users who attempt to access the site receive an access-denied message.

Thursday, December 13, 2012

Manage blocked file types (SharePoint Server 2010)

Add or remove blocked file types
Use this procedure when you want to prohibit files of a specific type from being saved or retrieved from any Web application on a server.
To add or remove blocked file types by using Central Administration
  1. Verify that you have the following administrative credentials.(You must be a farm administrator on the server.)
  2. In Central Administration, click Security.
  3. On the Security page, in the General Security section, click Define blocked file types.
  4. On the Blocked File Types page, if you want to change the selected Web application, on the            Web Application menu, click Change Web Application. Use the Select Web Application page to select a Web application.
  5.  Do one of the following:
  • To block an additional file type, scroll to the bottom of the Type each file extension on a separate line text box, type the file extension you want to block, and then click OK.
You do not have to type a file extension in the list in alphabetical order. The next time you open the list, the file extension you added will be correctly sorted in alphabetical order.

· To stop blocking a file type, select a file type from the list, press the Delete key, and then click OK.

Monday, December 10, 2012

Install Timer Job by Management Shell

Add-SPSolution "filepath"
Install-SPSolution -Identity “wspname” -GACDeployment
Enable-SPFeature “feature name” -url “Siteurl
If you get an error then
Disable-SPFeature “feature name”  -url “Siteurl
Then again enable
Enable-SPFeature “feature name”  -url “Siteurl

How to launch a document by clicking a link to the file?

Word: <a href='ms-word:ofe|u|path/to/web/word/document.docx'>Link to document</a> Excel: <a href='ms-excel:o...