CUSTOMIZATION QUESTIONS
1. What is Sandbox solution?
When user writes custom code, the code is not trusted, its failure can influence entire site. So the sandbox solution concept is used. In that case, program is only written for particular site & solution is uploaded in the same site. The solution size limit is decided at the time of site creation & if size increases or code shows bad performance then it will be easy for the administrator to stop the working of solution.
2. What can be deployed as a Sandbox solution in SharePoint 2010?
Users can deploy the below four things as sandboxed solutions:
1. WebParts.
2. Event Receivers.
3. List Definitions.
4. Workflows.
3. What are the Visual Studio 2010 Tools for SharePoint?
Visual Studio 2010 includes SharePoint-specific project types and project item types, and includes powerful packaging, deployment, and debugging features that help increase the efficiency as a SharePoint 2010 developer. Some of the Templates available are:
1. Visual Web Part project template.
2. List definition template.
3. Content Type template.
4. Empty Project template.
5. Event Receiver template.
6. Some workflow template.
7. the Site Definition template And many more....
4. How does Client object model works?
When developer use SharePoint client API’s to perform a specific task, the SharePoint 2010 managed client object model bundles up these uses of the API into XML and sends it to the server that runs SharePoint Foundation. The server receives this request, and makes appropriate calls into the object model on the server, collects the responses, forms them into JavaScript Object Notation (JSON), and sends that JSON back to the SharePoint Foundation 2010 managed client object model. The client object model parses the JSON and presents the results to the application as .NET Framework objects (or ECMAScript objects for ECMAScript).
5. How many types of Client Object model extension are available in 2010 and when would a developer use one or the other.
To develop rich client side solutions, three set of client-side APIs has been introduced in the Microsoft.SharePoint.Client namespace. The three APIs are targeted for three different types of clients.
1. .Net Managed applications – These are used when we have to create console applications or window applications, web applications which are not running inside SharePoint Context.
2. For Silverlight applications
3. ECMAScript – It is a client object model extension for using with JavaScript or JScript. This is used for creating applications, which are hosted inside SharePoint. For example, web part deployed in SharePoint site can use this JavaScript API for accessing SharePoint from browser using JavaScript.
6. How does user access ECMAScript object model API’s?
The ECMAScript library is available in a number of JS files in the LAYOUTS folder. The main file among number of .js files is SP.js. When developer includes this file in the APSX page using a ScriptLink control, all other required JS files are loaded automatically. By linking SP.js to the page, the SP namespace is registered. SP is the SharePoint namespace that contains all objects. For debugging purposes, every js file also has a ‘debug’ equivalent in the same folder.
7. What are the Authentication methods for the client object model application?
A developer can use three authentication options while working with the Client Object Model in SharePoint 2010:
1. Anonymous
2. Default
3. FormsAuthenticationDeveloper can specify clientContext.Authentication = Anonymous\Default\FormsAuthentication, If developer do not choose an authentication method in the code, the application will by default start using the client’s Windows Credentials (DefaultCredentials).
8. How can a developer write efficient and better performing client object applications?
Developer can always use Lambda expressions in their queries to return only specific properties that will be used in the block. Developer can also use LoadQuery() method and specify multiple levels of properties to load for e.g. while returning specific properties of the lists using LoadQuery(), developer can also specify the fields to return from each list to optimize the data access.
9. What is difference between Load() and LoadQuery() methods?
Load method populates the client object directly with what it gets data from the server i.e. a collection object like ListItemCollection etc. but LoadQuery returns the data as a completely new collection in IEnumerable format.
Other major difference is that the Collections that user load using the Load() method are eligible for garbage collection only when the client context variable itself goes out of scope whereas, in these collections go out of scope at the end of IEnumerable<List> list.
10. What is difference between Load() and LoadQuery() methods?
Load method populates the client object directly with what it gets data from the server i.e. a collection object like ListItemCollection etc. but LoadQuery returns the data as a completely new collection in IEnumerable format. Other major difference is that the Collections that user load using the Load() method are eligible for garbage collection only when the client context variable itself goes out of scope whereas, in LoadQuery() collections go out of scope at the end of IEnumerable<List> list.
11. What is the purpose of calling clientContext.ExecuteQuery()?
ExecuteQuery gives developer the option to minimize the number of roundtrips to the server from the client code. All the components loaded into the clientcontext are executed in one go.
12. What is REST?
How it is used in SharePoint 2010? REST (Representational State transfer) is a protocol (powered by ADO.NET services) which is used for getting data out of SharePoint via URL. It is mostly used to access data from SharePoint even when user is not in the SharePoint context.
13. What data type does REST return?
REST does not return an object of type SharePoint Site\List. Instead, it returns an XML output.
14. Why would a developer use LINQ over CAML for data retrieval?
Unlike CAML, with LINQ to SharePoint provider, developers are working with strongly typed list item objects. For example, an item in the Announcements list is an object of type Announcement and an item on a Tasks list is an object of type Task. Developer can then enumerate the objects and get the properties for their use. In addition, developer can take benefit of LINQ syntax and the LINQ keywords built into C# and VB for LINQ queries.
15. What are the Disadvantages of Using LINQ in the Code?
LINQ translates the LINQ queries into Collaborative Application Markup Language (CAML) queries thus adding an extra step for retrieving the items.
16. What does AllowUnsafeUpdates do?
If developer is trying to modify Windows SharePoint Services data using code, developer may need to allow unsafe updates on the Web site, without requiring a security validation. For this, developer needs to set AllowUnsafeUpdates property to true.
17. What does RunWithElevatedPrivileges do?
There are certain object models that call another model that require site-administration privileges. To bypass access-denied error, we use RunWithElevatedPrivileges property when a nonprivileged user initiates request. We can successfully make calls into the object model by calling the RunWithElevatedPrivileges method provided by the SPSecurity class.
18. How is a Content type deployed?
Content Type can be deployed and associated with list using feature.
19. What is the scope of a content type?
A site content type becomes available to lists and document libraries within the site in which the content type is created and to the lists and document libraries in any child site.
20. What is an ancestral type and what does it have to do with content types?
An ancestral type is the base type that the content type is deriving from, such as Document (0x0101). The ancestral type will define the metadata fields that are included with the custom content type.
21. Can a list definition be derived from a custom content type?
Yes, a list definition can derive from a content type, which can be seen in the schema.XML of the list definition in the element.
22. When creating a list definition, how can a user create an instance of the list?
User can create a new instance of a list by creating an instance.XML file
23. What are application pages?
An application page is the best type of page to create, when there is need to add custom code. Application pages are stored on the file system of the front-end Web server in the %Program Files\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\LAYOUTS directory. They allow in-line code without restriction. They cannot use dynamic Web Parts or Web Part zones or be modified using SharePoint Designer. Application pages are not tracked in the content database. They never run in safe mode. Since application pages must be deployed inside the SharePoint Root directory hence, they cannot be used within sandboxed solutions.
24. When to use application pages?
1. These are generally used as administrative pages.
2. These pages can be used where we want to capture data.
3. These pages can be used for configuration pages.
4. These pages can be used where we want to restrict the users to customize the page.
5. Application pages can be used with any site or site collection or web application on same server.
6. These pages are used when we want to add custom code or inline code to the page.
25. What is difference between an Application page and a Custom aspx page in SharePoint 2010?
Application Page – Developer would typically use an application page when developer need some content that is merged with SharePoint master page. A master page enables application pages to share the same appearance and behavior as other pages on a site. Application page generally is deployed in _layouts and inherits the look and feel of the site that developer is using.
A Custom .net aspx page on the other hand would need content and master page tags in the page to make it inherit the look and feel of the site.
26. How to create a custom master page?
There are multiple ways to create custom master page files
1- By copying and editing existing master page.
2- By SharePoint Designer.
3- By editing minimal.master using editor.
27. How to apply a custom master page?
There are two ways to apply a custom master page
1. Custom Master Page can be deployed using SharePoint Feature by which master page gets uploaded to the master page gallery.
2. Custom master page can be uploaded directly in master page gallery library and apply the same master page using site and system master page option in Site Settings page by selecting Master Page option.
28. How to link the custom CSS file in the master page?
Custom CSS files can be linked to the master pages with the help of a class called Sharepoint:CssRegistration
29. If a developer creates a new CSS file then where should the file be stored?
The css file can be stored in two locations, either in the document library or in the layouts folder.
30. How to create custom Themes?
Custom themes can be created for SharePoint by two ways.
1- Creating a theme in Microsoft PowerPoint.
2- Themes can also be created with the help of Visual Studio.
31. What does safe control means?
SharePoint application runs in Full Trust mode. For Web Parts to work properly in SharePoint Sites, its entry in web.config file assures Full Trust to SharePoint Site as it is registered in the file as safe.
32. What is Custom Control?
Custom controls have a file extension as “.ascx”, and are shared across web applications. There is no visual designer for creating custom controls hence, user cannot drag and drop custom controls.
33. What is Content query web part?
Content query web part displays a dynamic set of items based on a query that user build by using a web browser. The query displays selected items. User can set presentation options to determine how these items are displayed on the finished page.
34. How to debug a web part?
A web parts can be debugged in visual studio using following steps.
1. Set the break points
2. Attach the ASP.Net w3wp.exe process
3. Debug by tracing, change trace level in web.config
< Trace enabled ="true" pageOutput = "true"/>
35. Can a modal dialog be displayed from a webpart?
Yes, a modal dialog can be displayed from within a webpart code since it is a JavaScript block that can be registered on the page.
36. While creating a Web part, which is the ideal location to initialize the web controls?
Override the CreateChildControls() method to include web controls. Developer can control the exact rendering of the controls by calling the Render method.
37. How will developer use WebParts or other solutions created in SharePoint 2007 in SharePoint 2010?
In SharePoint 2010 the 12 hive is now replaced by 14 hive, so developer will rewrite and recompile any code that refers to files and resources in “12″ hive. In addition to developer must recompile custom code written for Windows SharePoint Services 3.0 and Office SharePoint Server 2007 that does not run on IIS
38. Can Developer modify the Out-of-Box workflows in SharePoint 2010?
In SharePoint 2010, developer has an option to customize the Out-of-Box workflows. The four most popular workflows in SharePoint Server 2010 —
the Approval,
Collect Feedback,
Collect Signatures,
Publishing Approval workflows
— have been completely rebuilt as declarative reusable workflows, meaning that they are now fully customizable in SharePoint Designer 2010
39. When is workflow forms created? And how to customize it?
SharePoint Designer 2010 automatically generates the forms, but user can customize them by going to the settings page for the workflow, in the Forms section, click the form user want to customize. Workflow forms are either InfoPath or ASP.NET pages. They are stored on the SharePoint site with the workflow source files.
40. Where are the InfoPath forms published in SharePoint?
InfoPath forms are published in the Manage Form Template in Central Administration site or to a list or a form library in a site collection.
41. What is Features in SharePoint?
Feature is a functional component, which contains various SharePoint elements. Features have their own receiver architecture, which allow user to trap events such as when a feature is installed, uninstalled, activated, or deactivated. User can define several element types in features like menu command, template, page instance, event handler, workflow, list instance, list definition, and link commands. Features in SharePoint allow users to easily package up functionality that can be deployed and installed across the server farm. Features provide a mechanism by which user can package the files that a solution needs, such as content types, Web Parts, lists, and site definitions, master page. Inside the Feature, the feature.xml file contains references to all the element manifests within that Feature, pluggable behavior for installing or uninstalling Features within a deployment, pluggable behavior for activating or deactivating Features at a given scope, scoped property bag for storing data required by a Feature within its scope.
42. What is the scope of feature activation?
Feature can be activated or deactivated at various scopes throughout a SharePoint instances, such as farm level,
web application level,
site collection level,
web level, etc.…
43. What is the difference between feature definition and feature instance?
The feature definition is the set of source files in the Visual Studio 2010 project that is deployed using a solution package. Once deployed, a feature definition is a set of template files and components that reside on each front-end Web server. A feature instance is what is created when a user activates the feature definition
44. What are the minimum files required for a feature?
Every feature directory should contain at least one file namely feature.xml and should be placed in the root of the directory. But a feature directory can contain one or more xml files as well as resource files such as image files, css files or js files. A feature.xml file contains attributes like Id, Title, Description, Version, Scope, Hidden, and ImageURL.
45. What is hidden attribute in a feature?
Hidden attribute will take the value of True or False. If it is set to False, after installation the feature definition can be seen by administrators only.
46. What is Elements.xml file in Feature in SharePoint 2010?
Elements.xml file contains the actual feature element. It can contain elements like ListInstance, Field, ContentType, ListTemplate, Workflow, WorkflowActions etc.
47. What is Feature Receiver in SharePoint 2010, its base class along with the methods that needs to be override?
A Feature Receiver allows user to write event handlers in a managed programming language such as C# or Visual Basic. These event handlers are executed during feature specific events such as feature activation and feature deactivation. The base class is SPFeatureReceiver. The methods to be overridden are: FeatureActivating, FeatureActivated, FeatureDeactivating,FeatureDeactivated etc.
48. How are features created?
Feature can be created by creating a new Empty SharePoint project from VS 2010 and then add new item named feature. After user has created the project, right click on the "Features" node in "solution explorer" and "add feature". This will create a new feature with the title "Feature1". User can rename it or leave it as it is. On double clicking the name of the feature, the properties of the feature will appear, such as title, description and the scope. Right click on the "feature1" in solution explorer and click on "Add feature Receiver" to add it. After the file has been created, uncomment (as required) the "on activate" and/or “on deactivate" and put code in there.
49. How can a feature be deployed?
There are two ways for deploying a feature
1- WSP builder via Visual Studio and activate solution from central admin.
2- Using STS Command, firstly install and then activate.
50. Where the feature receiver file needs to be deployed?
The feature receiver file needs to be deployed in Global Assembly cache (GAC).
51. What is a Manifest.xml File in SharePoint 2010?
Manifest.xml file contains the Meta data of a solution package. At the time of deployment, SharePoint inspects manifest.xml file to determine which template files it needs to copy into the SharePoint root directory.
52. Can a page be displayed as a modal dialog?
Yes, any page can be displayed as modal dialog. A Modal dialog takes options as a parameter and developer can specify the URL for any page usually saved in _layouts.
53. What is New in SPALerts?
In SharePoint 2007, alerts were sent only through e-mails, but in SharePoint 2010, users can also send an alert to mobile devices as SMS Message. A New property DeliveryChannels is introduced to indicate, whether the alert is delivered as E-mail or as an SMS Message.
Source: Vishal Gupta SharePoint Interview Questions