SharePoint Interview Questions and Answers
Q. Explain Below code
using (SPSite site = new SPSite(SPContext.Current.Web.Url)) // Gets the absolute url of the website
using (SPWeb web = site.RootWeb) // Gets the root website of site collection
using (SPWeb web = site.OpenWeb())// OpenWeb accepts either GUID of sites or site URL if a parameter is blank means returns the site associated with the current URL
SPWeb – Represents SharePoint service websites
SPSite – Represents a collection of sites in a web application.
SPWebApplication – Represents and IIS web application.
SPWebCollection – Represents a collection of SPWeb object.
SPWebTemplate – Represents a site definition or site template that is used to create SharePoint sites.
SPList – Represents a list on SharePoint Site.
SPListCollection – Represents a collection of SPList object.
SPListItem – Represents a list item or row.
SPListItemCollection – Represents a collection of SPListItem object
Base class for Timer Job – SPJobDefinition
Base class for Event Receiver – SPItemEventReceiver
You may visit Server Object Model (SOM) implementation in SharePoint 2013 here – http://www.sharepointcafe.net/2017/09/server-object-model-programming-sharepoint-2013.html
Q. Write basic code to interact with SharePoint List.
Server Object Model:
using (SPSite site = new SPSite(SPContext.Current.Web.Url))
{
using (SPWeb web = site.OpenWeb())
{
SPList list= web.Lists[“MyList”];
SPListItemCollection items= list.GetItems();
web.AllowUnsafeUpdates = true;
foreach (SPListItem item in items)
{
item[“Title”] = “New Title”; item.Update();
}
web.AllowUnsafeUpdates = false;
}
}
Client Object Model:
ClientContext context1 = new ClientContext(Constants.SITE_URL);
context1.AuthenticationMode = ClientAuthenticationMode.Anonymous;
List list1 = context1.Web.Lists.GetByTitle(“ListName”);
CamlQuery query1 = new CamlQuery();
query1.ViewXml = @”<Where><IsNotNull><FieldRef Name=’Title’ /></IsNotNull></Where><OrderBy><FieldRef Name=’ID’ Ascending=’False’ /></OrderBy>”;
Microsoft.SharePoint.Client.ListItemCollection listCollection1 = list1.GetItems(query1);
context1.Load(listCollection1);
context1.ExecuteQuery();
DataTable dTable1 = new DataTable();
dTable1.Columns.Add(“Title”);
for (int iCntr1 = 0; iCntr1 < listCollection1.Count; iCntr1++)
{
dTable1.Rows.Add(dTable1.NewRow());
if (listCollection1[iCntr1][“Title”] != null)
{
dTable1.Rows[dTable1.Rows.Count – 1][“Title”] = listCollection1[iCntr1][“Title”].ToString();
}
}
Q. What is CAML Query? How to write CAML Query?
CAML stands for Collaborative Application Markup Language. It is an XML based language that is used in SharePoint.
CAML query generally used on SharePoint objects like List, Library, List Template, Content Type etc. To know more about SharePoint CAML Query and implementation, please click here.
Q. Page Parser Path in SharePoint
There is a limitation in SharePoint, script with runat server code not allowed in Application Pages.
By adding below piece of code it can be done.
<PageParserPath VirtualPath=”/myFiles/*” CompilationMode=”Always” AllowServerSideScript=”true” IncludeSubFolders=”true”/>
</PageParserPaths>
Now you may add below code to your page:
<script runat=”server”>
protected void Page_Load(Object sender, EventArgs e)
{
Response.Write(“Server side code”);
}
</script>
Q. Allow unsafe update vs run with elevated privileges
Allow unsafe update is set to true when we are updating the content database to avoid external injections.
RWEP – It executes method with full rights even if the user does not otherwise have full control.
SPSecurity.RunWithElevatedPrivileges(delegate()
{ using (SPSite site = new SPSite(web.Site.ID))
{ // implementation details omitted
} });
Q. Safe Control in SharePoint
In SharePoint development environment a developer can add aspx file which may contain affect SharePoint environment, i.e. there might be a security risk.
To reduce the risk SharePoint allows adding safe control tag in web.config file to avoid script injection
Q. Timer Job in SharePoint
It is a job in SharePoint that runs in the background on a specified periodic basis.
http://www.sharepointcafe.net/2015/06/timer-job-in-sharepoint-2010-how-to.html
Q.Throttling and Indexing in SharePoint
List in SharePoint is similar to SQL table, indexing on List improve the performance. A SharePoint list allows 20 indices. Not all column type can be indexed. Throttling is a process which set the limit of an item that will be accessed in a single request. The default limit is 5000.
http://www.sharepointcafe.net/2015/07/throttling-and-indexing-in-sharepoint.html
List threshold can be overridden by using below property
SPList.EnableThrottling
for more visit this link:http://www.sharepointcafe.net/2015/07/throttling-and-indexing-in-sharepoint.html
Q. Create Child control in SharePoint
It does most of the rendering work related to a control such as a label control, textbox control etc.
LoadControl(usercontrolpath) is a method which loads web controls as per specified path.
Q. Web part properties using C# code
Below code is to set web part properties like width, chrome type, back color
Q. What is GAC?
GAC stands for Global Assembly Cache
Q. Audience Targeting in SharePoint
It is a way to display list, library items to specific groups of people. Go to list or library setting ->General Settings -> Audience targeting settings
Enable Audio targeting and click on ok. Now go to list or library select any item, click on the arrow and select edit properties. You will now see an option for Audience Targeting.
Q. What is view in SharePoint?
A view is a way to choose what data you want to present over web page.
There are:
Standard View
Calendar View
DataSheet View
Gantt View
Custom View (In SharePoint Designer)
Q. Create a different view for folder inside a document library
Q. Document Set in SharePoint
Provides the content types required for creating and using document sets. Create a document set when you want to manage multiple documents as a single work product.
Q. ULS Log in SharePoint
ULS stands for Unified Logging Service
ULS helps a developer to find bugs without debugging an application.
Q. SPSiteDataQuery in SharePoint
It is used to get data from multiple lists, and those lists could be on the same site or in multiple sites.
CrossListQueryInfo is an another way to do this but internally it uses SPSiteDataQuery .
In SPSiteDataquery there are 2 scopes that can be defined.
<Webs Scope=”Recursive” /> – Current website and all sub sites
<Webs Scope=”SiteCollection” /> – All websites that are in current site collection
Q. Permission levels in SharePoint.
Design – View, add, update, delete, approve
Contribute – view, add, update and delete items
Read – view pages and list items and download documents
Limited Access – Can view specific lists, document libraries, list items, folders or document on given permission
Q. Application Pages vs Site Pages
Application Pages stored in hive folder.
Site Pages stored in content database.
Application Pages support code behind.
Site Pages do not allow code behind.
Q. Data View Web Part
It is a way to display data with filtering. grouping. Data View web part was available in SharePoint 2007 and also available in 2010.
SharePoint 2010 also have XSLT List view web part.
XSLT Listview web part – It is a web part that can be modified in SharePoint designer using XSLT code.
Q. ONET.xml file
It is the core of site definition. It is located under hive folder.
Q. What are master pages available in SharePoint?
You can get more interview questions related to SharePoint master page.
v4.master – Default team site master page.
default.master – This is the default master page for SharePoint 2007 look and feel.
minimal.master – Generally used by search centers.
simple.master – Used by SharePoint 2010 general pages like login page. error page, signout page etc.
Q. What is a Term?
A term is a keyword or phrase that can be associated with an item. A term set is a collection of related terms.
Q. Access Denied by Business Data Connectivity – Error in External List
Go to Central Admin-> Manage Service Application -> Click on Business connectivity service->
Select your External Content Type Name and click on Set Object Permission from top ribbon.
Type account name, then Add and select operation that you want to allow for this user.
Refer Below Screen –
Q. Feature and Scope of feature available in SharePoint:
A feature is a set of code or functionality that can be activated or de-activated at various level to perform some change in SharePoint site.
Farm – It affects all web application available in a farm.
Web Application- It affects a complete web application.
Site- It affects a single site collection.
Web – It affects a single site
Q. Event Receiver
Event Handler and Receiver
There are 2 types of Events Before and After.
Generally known as Synchronous and Asynchronous events.
Event Receiver Base Class:
SPItemEventReceiver
SPListEventReceiver
SPEmailEventReceiver
SPWebEventReceiver
SPWorkflowEventReceiver
Event handler gets registered in Elements.xml file. It includes Class name, assembly name, List template id.
If any method removed/added in receiver class same will reflect in Elements.xml file.
SPItemEventProperties
properties.AfterProperties[“Title”].ToString();
properties.Status = SPEventReceiverStatus.CancelWithRedirectUrl;
properties.RedirectUrl = “_layouts/EventRcvrApp/Error.aspx?msg=Item+Cannpt+be+deleted”;
Q. Application Page vs Site Page vs Custom ASPX Page
Application Page | Site Page | Custom Page |
Support Code behind | Do not support code behind | Can have code behind, but code-behind file will not be deployed |
They inherit from application.master | They inherit custom look of the site | Need to specify the URL of the custom master page |
Stored in layout folder available in hive folder | Stored in content database | Deployed in layout folder |
So that’s all for SharePoint 2010 interview questions and answers.
If you have more questions related to SharePoint 2010 interview, please put the same in the comment section.
You may like this –
Top 30 SharePoint 2013 Interview Questions and Answers for Developer
Web API Interview Questions and Answers
You may read some popular blogs on SharePointCafe.Net |