Posts

Showing posts with the label SharePoint 2010

Copy List Item Programmatically

public void CopyItem(SPListItem srcItem, SPListItem destItem) { foreach (SPField field in srcItem.Fields) { if (!field.ReadOnlyField && field.InternalName != "Attachments") { destItem[field.InternalName] = srcItem[field.InternalName]; } } foreach (string attachmentName in srcItem.Attachments) { SPFile file = srcItem.ParentList.ParentWeb.GetFile(srcItem.Attachments.UrlPrefix + attachmentName); byte[] data = file.OpenBinary(); destItem.Attachments.Add(attachmentName, data); } destItem.Update(); }

December 2014 Cumulative Updates For SharePoint 2010

The Cumulative Update (December 2014) for SharePoint 2010 has been released : SharePoint Foundation: http://support2.microsoft.com/kb/2899585 SharePoint Server 2010: http://support2.microsoft.com/kb/2899583 Project Server 2010: http://support2.microsoft.com/kb/2899587 Office 2010 : http://support2.microsoft.com/kb/3020815

What is Managed Path in SharePoint

Let’s understand what is path first. In SharePoint you have seen some different types of site collection urls within same Web Application like : ·         http://sharepointDemo ·         http://sharepointDemo/subsite ·         http://sharePointDemo/Subsite/SubSubsite ·         http://SharePointDemo/Sites/Contoso ·         http://SharePointDemo/Sites/Contoso/SubSite These different kind of URL structure called path & you can manage these path as per you your organization hierarchy or architecture. Some time you required to create a site collection with name of “Departments” & under this “Department” you might want to create some departments like HR, IT etc. and you want your site collection url should be like http://SharePointDemo/Departments/HR . Managed path is this. Where you can manage site collection pa...

Get web.config file in timer job

I was working on timer job & wanted to get data from sql server. To achive this goal, I add my database connection string in web application’s web.config file. Now I used the following code to get web.config setting from timer job : private string getConnectionString()         {             return System.Configuration.ConfigurationManager.AppSettings["MyAppSettingKey"];        } But this code was not able to get the web.config file. Why? I started some R & D on it & found that Time Job runs under OWSTimer.exe & Web Application runs under W3WP.exe. As the context of  Both are different so we have to use WebConfigurationManager to get specific SharePoint Web Application configuration. private string getConnectionString(string webAppName)         {      ...

What is Managed Path

Let’s understand what is path first. In SharePoint you have seen some different types of site collection urls within same Web Application like : http://sharepointDemo http://sharepointDemo/subsite http://sharePointDemo/Subsite/SubSubsite http://SharePointDemo/Sites/Contoso http://SharePointDemo/Sites/Contoso/SubSite These different kind of URL structure called path & you can manage these path as per you your organization hierarchy or architecture. Some time you required to create a site collection with name of “Departments” & under this “Department” you might want to create some departments like HR, IT etc. and you want your site collection url should be like http://SharePointDemo/Departments/HR . Managed path is this. Where you can manage site collection path not whole url. Here you can Manage Path for the selected Web Application. In other words, when you creates your first site collection in Web Application you have to provide site collection url un...

My Favorites

Image
This  is SharePoint 2010 project for creating bookmarks for any item or document which can be a list item (like Custom list, Task list etc.) or a document stored in any document library. “My Favorites” works on Site Collection level. When you install My Favorites and activate the feature, You will get two new items in your Edit Control Block menu (ECB menu) called “Mark as Favorites” & “Remove Favorites”. When you click on “Mark as Favorite”, you will get a entry form where you can add comments for the current selected item or document. When you click on the link next to “Item Title” label, you can get a display form of the selected item. Add your comment here if you want. Then click on the save button and the form will close. When you click on the “Remove Favorite” item in ECB menu, you will get same form but with some different option like Comment will be read only and you will see delete button instead of Save button. Yo...

SharePoint 2010 Interview Questions – IT Pro / Architect

Basic Intro SharePoint Architecture Questions 1) What are Web Applications in SharePoint? An IIS Web site created and used by SharePoint 2010. Saying an IIS virtual server is also an acceptable answer. 2) What is an application pool? A group of one or more URLs that are served by a particular worker process or set of worker processes. 3) Why are application pools important? They provide a way for multiple sites to run on the same server but still have their own worker processes and identity. 4) What are zones? Different logical paths (URLs meaning) of gaining access to the same SharePoint Web application. 5) What are Web Application Policies? Enables security policy for users at the Web application level, rather than at the site collection or site level. Importantly, they override all other security settings. 6) What is a site collection?  A site collection contains a top-level website and can contain one or more sub-sites web sit...

Hide buttons control from ribbon for specific list

Image
Hi , I want to hide "New Folder" button from ribbon of my library "Shared Documents" for site "SP2010-01".     To hide this button from ribbon for a Shared Documents, You must write this code : using (SPSite site = new SPSite("http://SP2010-01")) { using (SPWeb web = site.OpenWeb()) { SPList list = web.Lists.TryGetList("Shared Documents"); web.AllowUnsafeUpdates = true; SPUserCustomAction actionView = list.UserCustomActions.Add(); StringBuilder newurl = new StringBuilder(); newurl.AppendLine("<CommandUIExtension>"); newurl.AppendLine("     <CommandUIDefinitions>"); //Provide Location ID to hide the button newurl.AppendLine("        <CommandUIDefinition Location=\" Ribbon.Documents.New.NewFolder \">"); newurl.AppendLine("        </CommandUIDefinition>"); newurl.AppendLine("    </CommandUIDefinitions>");...

DateTimeControl is not showing it’s calendar in proper format

Image
Hi, Some time we have to create our own customized asp form or visual web part or simple web parts where we use SharePoint’s Date Time Control . Some time that control works properly but some time this control does not show calendar in proper format as we see in SharePoint. Control should show calendar like : But instead of the format, It shows like this : If you want to change this format for default format you have to write this code: dateTimeControl1.DatePickerFrameUrl=ResoulveRul(SPContext.Current.Site.Url+”/_layouts/iframe.aspx”);

Make Read Only or Hide Fields in SharePoint 2010

Hi , If you want to make field as read only or hide fields , you must read this article. It is too good. Just download files & install as instructed. To read full article :  SPUtility To read documents : Documents To download code files : Download

How to show appended fields on the forms ?

Add this tag on the form where you want to display versions : < SharePoint:AppendOnlyHistory runat ="server" ControlMode ="Display" FieldName ="Manager_x0020_Comments" ItemId ="{@ID}"/> You just need to change field name value. FieldName property always contains only internal name of the field.

Make fields Disable / Read only on Entry Forms

If you want to disable fields on New Entry Form or Edit Entry form, Use this code to disable fields : // Function To Disable Fields   function disableField(title)   {    for(var i = 0; i < document.all.length; i++)    {     var el = document.all[i];     // find html element with specified title     if(el.title == title)     {      el.disabled = true; // disable      // if the next element has a reference to the current element      // then disable if as well      if(i < document.all.length - 1)      {       var el2 = document.all[i + 1];       if(el2.outerHTML.indexOf(el.id) > 0)       {      ...

SharePoint 2010 CSS Reference Chart

SharePoint 2010 CSS Reference Chart: A Complete reference for SharePoint 2010 CSS. You must read it. http://sharepointexperience.com/csschart/csschart.html

List inspector

Image
List inspector http://sharepointjavascript.wordpress.com/2012/02/05/list-inspector-ed-macintosh/

Preview list item on hover

Very good article with code on How to show preview of list item on hover. http://sharepointjavascript.wordpress.com/2012/02/12/list-view-preview-item-on-hover-sharepoint-2010/

Maintain file version history when moving/copying files between SharePoint sites

A very good article on how to maintain file version history when moving/copying files between SharePoint sites. You must read it. I has an example of code which demonstrates how to do. http://sharepointvenividivici.typepad.com/sharepoint-customization/2011/06/maintain-file-version-history-when-movingcopying-files-between-sharepoint-sites.html

Delete a List or list Item and Store into Recycle Bin

Use Recycle() Method to move your List or List Item into Recycle Bin. i.e. : spListObject.Recycle(); spListItemObject.Recycle();

Creating a Custom Email Validation Field in SharePoint 2010

A very good article on How to create a custom field in SharePoint 2010. http://www.c-sharpcorner.com/uploadfile/Roji.Joy/creating-a-custom-field-type-for-sharepoint-2010-email-validation-field/

SharePoint 2010 Limits and boundaries

Reference : http://technet.microsoft.com/en-us/library/cc262787.aspx#Overview Web application limits The following table lists the recommended guidelines for Web applications. Limit Maximum value Limit type Notes Content database 300 per Web application Supported With 300 content databases per Web application, end user operations such as opening the site or site collections are not affected. But administrative operations such as creating a new site collection will experience decrease in performance. We recommend that you use Windows PowerShell to manage the Web application when a large number of content databases are present, because the management interface becomes slow and difficult to navigate. Zone 5 per Web application Boundary The number of zones defined for a farm is hard-coded to 5. Zones include Default, Intranet, Extranet, Internet, and custom. Managed path 20 per Web application Supported ...