Monday, December 16, 2013

Extension methode for web.AllowUnsafeUpdates


How we do it:

using (SPSite site = new SPSite(SPContext.Current.Site.Url))
            {
                using (SPWeb web = site.OpenWeb())
                {
                        web.AllowUnsafeUpdates = true;
                        SPList list = web.Lists.TryGetList("TestExtensionList");
                        SPListItem item = list.Items.Add();
                        item[SPBuiltInFieldId.Title] = TextBox1.Text.Trim();
                        item.Update();
                        web.AllowUnsafeUpdates = false;
                }

            }

How we can do it:


using (SPSite site = new SPSite(SPContext.Current.Site.Url))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    web.DoUnsafeUpdate(delegate()
                    {
                        SPList list = web.Lists.TryGetList("TestExtensionList");
                        SPListItem item = list.Items.Add();
                        item[SPBuiltInFieldId.Title] = TextBox1.Text.Trim();
                        item.Update();
                    });  
                }
            }

Tuesday, December 3, 2013

Creating connected web part in SharePoint 2010

Steps:
1. Create interface.
2. Create provider web part by implementing the interface created.
3. Create consumer web part.


Code blocks below:-


SharePoint connected Web Part not showing connections option

Possible reasons include the following:
  • You are not browsing a web part in edit mode. To set connection with other web part, Page should be in edit mode.
  • Web part connection not allowed in the Web Application. To enable web part connection follow below steps: 1)   Open the central administration
    2)   Application management
    3)   Web applications
    4)   Manage web applications
    5)   Select the web application for which you would like to enable the option
    6)   On the top-Ribbon-You will find an option as ‘webpart security’
    7)   Click on it and you will get one frame window which specifies ‘security for web pages
    8)   Here you will find the option of Web part connections
    9)   Select the option “Allows users to create connections between Web Parts”
    1)   Open the central administration
    2)   Application management
    3)   Web applications
    4)   Manage web applications
    5)   Select the web application for which you would like to enable the option
    6)   On the top-Ribbon-You will find an option as ‘webpart security’
    7)   Click on it and you will get one frame window which specifies ‘security for web pages
    8)   Here you will find the option of Web part connections
    9)   Select the option “Allows users to create connections between Web Parts”
    - See more at: http://sharepointknowledgebase.blogspot.in/2013/09/webpart-security-disable-web-part.html#sthash.gSlOHy8q.dpuf
    1)   Open the central administration
    2)   Application management
    3)   Web applications
    4)   Manage web applications
    5)   Select the web application for which you would like to enable the option
    6)   On the top-Ribbon-You will find an option as ‘webpart security’
    7)   Click on it and you will get one frame window which specifies ‘security for web pages
    8)   Here you will find the option of Web part connections
    9)   Select the option “Allows users to create connections between Web Parts”
    - See more at: http://sharepointknowledgebase.blogspot.in/2013/09/webpart-security-disable-web-part.html#sthash.gSlOHy8q.dpuf
  • The web part is not added to Web Part Zone. The page should be Web part Zone Page.

More at:


Tuesday, November 19, 2013

Could not find stored procedure 'sp_dboption' while installing SharePoint with SQL 2012

To make use of SQL 2012 with SharePoint 2010 server should have SharePoint Service Pack 1 installed.


Or


You can go ahead with alter

http://beyondrelational.com/modules/2/blogs/28/Posts/15429/replacement-for-system-stored-procedure-spdboption-in-sql-server-2012-denali.aspx?utm_source=brdigest&utm_medium=email&utm_campaign=dailydigest



Cannot connect to the configuration database. SharePoint 2010

1. Run prompt
2. Type  Services.msc
3. Start SQL Server (MSSQLSERVER) service



Thursday, October 31, 2013

Client object Model managed Code C# SharePoint



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint.Client;

namespace SPClient.NetConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            ClientContext clientContext = new ClientContext("http://igtehydzbnv02:8811/");
            Web site = clientContext.Web;
            List list = site.Lists.GetByTitle("TestListFilter");
            CamlQuery query = new CamlQuery();

            ListItemCollection itemColl = list.GetItems(query);


            clientContext.Load(itemColl);
            clientContext.ExecuteQuery();
            Console.WriteLine("Count: {0}", itemColl.Count);


            for (int i = 0; i < itemColl.Count; i++)
            {
                Console.WriteLine(itemColl[i]["Title"]);
            }
            Console.ReadLine();

        }
    }
}

Show SharePoint Error Page instead of Yellow ASP.Net error page

To show SharePoint errorpage do below changes in Web.Config file:

<SafeModeMaxControls="200"CallStack="false"DirectFileDependencies="10"TotalFileDependencies="50"AllowPageLevelTrace="false">

and

<customErrorsmode="On" />


To See Error message on Page itself do below changed in Web.Config file

<SafeModeMaxControls="200"CallStack="true"DirectFileDependencies="10"TotalFileDependencies="50"AllowPageLevelTrace="false">

and

<customErrorsmode="Off" />

Monday, October 28, 2013

File deployment to Site Assest or Style Library SharePoint

1. Add Empty Module to Solution
2. Create root folder inside empty module
3. Create Sub folders for JS, Images, CSS files.
4. Do File specific changes in Element.xml file

Sample Element.xml

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="TestDeploy" Path="TestDeploy" Url="SiteAssets">
    <File  Url="BV/Sample.txt" Type="GhostableInLibrary"/>
  </Module>
</Elements>


Solution Snap Shot:-



Check dupliacte in list SharePoint ECMA Script : Client object model

Screen Shots:-

 
 Solution:-

Tuesday, October 22, 2013

Import / Export List in SharePoint using PowerShell

Exporting SPList :

 Export-SPWeb "<Site URL>" -itemurl "/Lists/<List Name>" -Path "D:\ListFolder\TestExport.cmp"


Importing SPList:

 Import-SPWeb -Identity "<Site URL>" -Path "D:\ListFolder\TestExport.cmp"



It will create list with same name in the target site.

Monday, October 14, 2013

Application pool keeps stopping / Service Unavailable in SharePoint Site / 503 error in SharePoint Site

One cause for this issue can be change in password for account with which Application pool is running for changing the Managed account password follow below blog post:
(Never change it from IIS directly)
 
If this is not your case then it can be below issue:
If you check the eventvwr logs you will see below entry in it:
The Module DLL 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\isapi\owssvr.dll' could not be loaded due to a configuration problem. The current configuration only supports loading images built for a x86 processor architecture.
 
Solution:
1.       Open IIS by typing inetmgr in RUN.
2.       Click on Application pools
3.       Click on particular Application pool for your site
4.       Right Click Advance settings
5.       Set Enable 32-bit applications to false


 

Saturday, October 12, 2013

Error While Adding/ Retracting SharePoint WSP

Error In PowerShell

Install-SPSolution : Admin SVC must be running in order to create deployment ti
mer job.


Error In Central Admin

The timer job for this operation has been created, but it will fail because the administrative service for this server is not enabled.






Solution:-

Monday, October 7, 2013

SharePoint Activate Feature using PowerShell


$spFeature= Get-SPFeature -Identity "<Feature Id from Feature.xml file>"

Enable-SPFeature $spFeature -Url "<Site Url>"

Thursday, September 26, 2013

SharePoint DateTime control not loading for some user (DateTimeControl Access denied )

It is a permission issue.
 
DateTimeControl field uses the iframe calender page to render the actual calender. The location of iframe.aspx is C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS
The problem appeared to be with managed paths in the site collections, the Users with "Contribute access" were accessing the following path:
http://myserver/_layouts/iframe.aspx (Path to Root site collection where user doesn't have access)
 
 
The solution:

Wednesday, September 25, 2013

Why to Dispose SPSite and SPWeb objects in SharePoint?


Several of the SharePoint Foundation objects, primarily the SPSite class and SPWeb class objects, are created as managed objects. However, these objects use unmanaged code and memory to perform the majority of their work. The managed part of the object is much smaller than the unmanaged part. Because the smaller managed part does not put memory pressure on the garbage collector, the garbage collector does not release the object from memory in a timely manner. The object's use of a large amount of unmanaged memory can cause some of the unusual behaviors described earlier. Calling applications that work with IDisposable objects in SharePoint Foundation must dispose the objects when the applications finish using them. You should not rely on the garbage collector to release them from memory automatically.

Simple PowerShell to get Event Receivers attached to SharePoint list


$spWeb = Get-SPWeb -Identity "SiteUrl"

$spList = $spWeb.Lists["ListName"] 

$spList.EventReceivers | Select Name, Assembly, Type

Friday, August 16, 2013

Cleared MCPD 70-576 exam / Prepartion material and links for 70-576


I sat for 70-576 – PRO: Designing and Developing Microsoft SharePoint 2010 Applications exam last Saturday and it went very well. I cleared the exam with good score. Though score was less than my last certification exam 70-573 I was happy to earn the score of 830 after spending lot of month for preparing myself for exam and getting the required confidence and Knowledge.

I discovered lot of SharePoint areas which were in dark for me before exam preparation. The amount of knowledge I gain is huge. Hoping that I will get chance to implemented all my learning in some of the projects I do then only it will stay with me forever and I will never forgot.

How I prepared for the exam?

There is no specific book which will cover all syllabus required for exam (even I don’t like reading book from start to end, I get lost in them). So the best way was to know the syllabus and learn all topics one by one with Google search.

While searching for the topic and learning I was gathering all the links in Excel for this blog post. Find below all relevant links for study:-





Wednesday, August 14, 2013

Throttling limits in SharePoint 2010


Limit
Maximum Value
Limit Type
File size
2 GB
Boundary
Documents
30,000,000 per library
Supported
Items
30,000,000 per list
Supported
List view lookup threshold
8 join operations per query
Threshold
List view threshold
5,000
Threshold
Unique security scopes
50,000 per list
Threshold
Indexes per list
20
Boundary
Datasheet view
50,000
Boundary
SharePoint Workspace
30,000  and 1800 documents
Boundary
Export to Excel
50,000
Boundary
Web Parts Per Page
25
Threshold
Groups user can belong to
5000
Supported
SharePoint groups
10,000 per site collection
Supported

Seven steps to build and deploy SPFX web part to SharePoint

Install Node.JS Use this link to install Node.JS https://nodejs.org/en/ 2.        Install yeomen and gulp CMD>npm install –g y...