Saturday, March 16, 2013
Button click event in web part
Wednesday, June 27, 2012
Restore List form web parts
1) Whenever user try to navigate to display form (either by hovering over list item in AllItems.aspx page or by clicking View Item in context menu of list item) user was directed to root web site.
2) Empty page even when accessed the page by hard-coding in url like site-url/lists/list-name/Dispform.aspx?ID=item_id
The ideal steps restore the list form web part is
1) Open the dispform.aspx of the list in SharePoint designer. Locate the cursor inside the loc:Main web part zone as shown below
2) Insert a List form Share Point control as shown below
3) Select the appropriate List and type of form as shown below
4) A new ListFormWebPart will be added to the page as shown below
5) Make a note of _WebPartID and ID parameter values from the newly added ListFormWebPart
In this case _WebPartID will be
ID will be
6) Now go to either edit form or new form of the list and take a copy of entire List form web part from it as shown below
7) In this copied List form web part replace _WenPartID and ID parameter values form the with the values copied in Step 5
8) Adjust the ControlMode and FormType values as per the form which needs to be corrected
9) Refer the below table for the appropriate values
Once these changes are incorporated the newly formatted ListFormWebPart is ready.
10) Now go the DisplayForm.aspx. Select the complete List form web part added in step 4 and remove it from the page. In that position add newly formatted ListFormWebPart
11) Save the DisplayForm.aspx page and close the designer.
12) Now ListFormWebPart is restored in the page and you can access DisplayForm.aspx as before.
Note : The same steps will work to restore deleted ListFormWebPart in EditForm.aspx and NewForm.aspx of the list. In that case values for ControlMode and FormType have to be selected appropriately as shown in table above.
Thursday, March 31, 2011
Elements of type 'Workflow' are not supported at the 'Web' scope. This feature could not be installed
Recently we were working on developing custom share point workflow which basically operates on any share point list/document library. We created a feature to activate/deactivate this workflow on sites.
Initially I had given the scope of this feature as "Site" (i.e. a site collection feature), later during code review I felt that as this feature and workflow basically operates on list and does not have any kind of dependency on any other list or item on the site collection I thought making the scope of this feature as "Web" (i.e. a Site Feature) is fair enough. When I restricted the scope of this workflow feature as "Web" and tried activating I got the error as "Elements of type 'Workflow' are not supported at the 'Web' scope. This feature could not be installed".
Through this I came to know that whenever we create a feature to activate/deactivate workflow the scope it should be Site (i.e. The workflow related feature should always be a Site Collection Feature).
Monday, December 27, 2010
Get sharepoint workflow name programmatically

While finding through various variables exposed by workflowProperties we found that it has a workflowProperties.TemplateName which stores this unique name.
Nothing big i said :) , but hopes that it may help someone while trying to access a workflow programmatically.
Friday, November 26, 2010
Share Point User Information List : Few Facts
1) We can't attach an Event Handler on this User Information List like any other list to capture user profile updation.
2) We can't create a custom search scope directly against User Information List.
3)User Info List has 2 Views namely a) Default View b) List View . These views only appear for all sharepoint groups in this site collection.
4) If we create a new view to display more custom fields the same view available for all the sharepoint groups.(i.e. If we want to change or create a new view for all sharepoint groups change it in this list as it is the root for all group members data)
Saturday, October 2, 2010
Find All The Sharepoint Groups For Which a User Belongs
Share point’s SPUser object has a property called SPUser.Groups which returns a SPGroupCollection which gives the collection of groups of which the user is a member.
Monday, September 6, 2010
Setting value of Read Only fields programmatically in Sharepoint
here)
Let us assume that I need to update 2 such column namely “Created By” and “Modified By” then code can be like
using (SPSite site = new SPSite(SPContext.Current.Site.ID))
{
using (SPWeb web = site.OpenWeb())
{
site.AllowUnsafeUpdates = true;
web.AllowUnsafeUpdates = true;
// Access the List
SPList list = web.Lists["Your_List_Name"];
// Access the item for which you want to update values
SPListItem listItem = list.Items[6];// choose the index corresponding to item
// Set the value for Created By field
listItem["Author"] = SPContext.Current.Web.CurrentUser;
// Set the value for Modified By field
listItem["Editor"] = SPContext.Current.Web.CurrentUser;
listItem.Update();
web.Update();
}
}
Like this we can programmatically set value of any field through its internal name.