Posts

Showing posts from March, 2011

Adding content type programatically

Scenario: You want to add Content Type programatically Solution: SharePoint Object Model Code: using  (SPSite site =  new  SPSite( "http://localhost" )) {       using  (SPWeb web = site.OpenWeb()) {       SPContentType baseType = web.AvailableContentTypes[ "Document" ];       SPContentType proposal =  new  SPContentType( baseType, web.ContentTypes,  "Project Proposal" );       proposal.FieldLinks.Add( new  SPFieldLink(web.AvailableFields[ "Author" ]));       web.ContentTypes.Add(proposal);       }   }  

Public Token key for the assembly

Scenario: Sharepoint require most of the assemblies to be strongly named and referenced using 4 part name of the assembly. Solution: You can use sn.exe utility to get the public token key for your assembly Code:      "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\sn.exe"  -T MyAssembly.dll   or           "C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\sn.exe"  -T MyAssembly.dll  

Increasing Site Template maximum size limit

Scenario:    You are not able to save a site template (.stp ) file because its size is bigger than 10MB. Solution:     STSADM allow you to change it. Code:     stsadm -o setproperty -pn max-template-document-size -pv 40000000  

SharePoint Development and Programming FAQ

http://social.msdn.microsoft.com/forums/en-US/sharepointdevelopment/thread/5834679b-482b-4924-b881-fa2146840d05

SharePoint Job – SPJobLockType – which one should you use ?

Please refer the following blog http://manomangaldas.blogspot.com/search?updated-min=2011-01-01T00%3A00%3A00-08%3A00&updated-max=2012-01-01T00%3A00%3A00-08%3A00&max-results=1

SharePoint Interview Questions

Please refer this blog http://manomangaldas.blogspot.com/search/label/Interview http://manomangaldas.blogspot.com/search?updated-min=2010-01-01T00%3A00%3A00-08%3A00&updated-max=2011-01-01T00%3A00%3A00-08%3A00&max-results=6

Add a custom menu in List Toolbar

Image
Using a Feature XML file, you can add a custom menu in a List Toolbar. The following image is a sample of the custom feature. There are couple of steps to create the List custom menu bar. Create a XML file, give a name to this file, e.g. "Test.xml". Add a "CustomAction " XML Element in this file. Add following attributes to this element: " RegistrationType="List" RegistrationId="100" Location="ViewToolbar" Sequence="1000" Title="Submit to Manager" Description="Custom List Action" Reference "Test.xml" file in "feature.xml"file using "ElementManifest Location='Test.xml' " XML schema. Install and activate this feature. Create a custom list from the site. You will see the custom menu "Submit to Manager" displaying on the List Toolbar.

Stsadm Commands for add/depoly solution

Addsolution : stsadm.exe –o addsolution –filename “C:\abc.wsp” Deploy Solution: stsadm.exe –o deploysolution –name abc.wsp –local –allowgacdeployment or stsadm –o deploysolution –name "abc.wsp” –immediate –allowgacdeployment -force or stsadm –o deploysolution –name "abc.wsp” –url http://localhost/ravi   –immediate –allowgacdeployment Upgrade Solution: stsadm.exe –o upgradesolution –name abc.wsp –filename “C:\abc.wsp” –immediate –allowgacdeployment Retract Solution: stsadm -o retractsolution -name abc.wsp -immediate The retractsolution operation removes files from the front-end Web server Remove Solution: stsadm -o deletesolution -name ab.wsp stsadm -o execadmsvcjobs : By using the STSADM operation execadmsvcjobs, we can force the timer job to execute immediately.This helps us when we donot want to wait until the scheduled time is reached Activate Feature: stsadm –o activatefeature –name <<YourfeatureName>> –url “ http://localhost/ravi ” -force Deactivate

Custom Site Definition in SharePoint

Steps to create custom Site Definition 1.  Log on as an administrator 2.  Browse to C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\SiteTemplates. Copy STS folder-> Paste it at same place -> Rename it as TIGER. 3.  Open the folder Tiger 4.  Search for default.aspx 5.  Open default.aspx in notepad. 6.  Modify code. Here we need to add code for site definition. Default.aspx <%@ Page language="C#" MasterPageFile="~masterurl/default.master"    Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage,Microsoft.SharePoint,Version=12.0.0.0,Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities"