Here i have consolidated some of interesting sharepoint questions ans answers. It may help you to take the sharepoint interview, If you want to get in to sharepoint project then you need to attend client interview then this sharepoint question and answer will help you to crack client interview.
1) What base class a WebPart you are going to use within Share Point 2007 can inherit from?
Ans: When inheriting from the SharePoint WebPart Base class your derived WebPart class will inherit from Microsoft.SharePoint.WebPartPages.WebPart. When inheriting from the ASP.NET 2.0 WebPart base class your derived WebPart class will inherit fromSystem.Web.UI.WebControls.WebParts.WebPart.
2) What are the differences between the two base classes and what are the inherit benefits of using webpart class.
It is considered good practice to use the ASP.NET WebPart base class if you are working on new webpart. Sharepoint base class is meant for backwards compatibility with previous version of SharePoint, however using sharepoint Webpart base call you can get four advanced functionality are:
- Cross page connections
- Connections between Web Parts that are outside of a Web Part zone
- Client-side connections (Web Part Page Services Component)
- Data caching infrastructure
3) What is the use of safe controls entry in web.config?
When you deploy a WebPart to SharePoint, you must first make it as a safe control to use within SharePoint in the web.config file. Entries made in the safe controls element of SharePoint are encountered by the SharePointHandler object and will be loaded in the SharePoint environment properly, those not will not be loaded and will throw an error.
4) Explain the Webpart life cycle.
Webpart life cycle also same as asp.net life cycle. Here you can find some additional events like CreateChildControls, RenderContents etc.
- Render (RenderContents, etc)
5) What is the CreateChildControls() method?
The CreateChildControls method in WebParts is used to notify the WebPart that there are children controls that should be output for rendering. Basically, it will add any child ASP.NET controls that are called instantiating each control with its relevant properties set, wire any relevant event handlers to the control, etc.
6) What does the RenderContents method do in an ASP.NET 2.0 WebPart?
The render contents method will render the WebPart content to the writer, usually an HtmlTextWriter since WebParts will output to an HTML stream. RenderContents is used to tell how the controls that are going to be displayed in the WebPart should be rendered on the page.
7) What is the WebPartManager sealed class? What is its purpose?
The WebPartManager sealed class is responsible for managing everything occurring on a WebPart page, such as the WebParts (controls), events, and misc. functionality that will occur in WebPartZones. For example, the WebPartManager is responsible for the functionality that is provided when you are working with moving a WebPart from WebPartZone to WebPartZone.
8) What is a SPSite and SPWeb object, and what is the difference between each of the objects?
The SPSite object represents a collection of sites (site collection [a top level sites and all its subsites]). The SPWeb object represents an instance SharePoint Web, and SPWeb object contains things like the actual content. A SPSite object contains the various subsites and the information regarding them.
9) When should you dispose SPWeb and SPSite objects? And even more important, when not?
You should always dispose them if you created them yourself, but not otherwise. You should never dispose SPContext.Current.Web/Site and you should normally not dispose SPWeb if IsRootWeb is true.
10) What is RunWithElevatedPrivileges? when you can use it?
RunWithElevatedPrivileges impersonates the identity of the current thread. In effect, this means that the code will run with higher level permission instead of using login user permission.
11) When running with SPSecurity.RunWithElevatedPrivileges (web context) what credentials are being used? What is the performance impact of RunWithElevatedPrivileges?
The App Pool Identity for the web application running SharePoint. Performance impact with RunWithElevatedPrivileges creates a new thread with the App Pool’s credentials, blocking your current thread until it finishes.
12) When modifying a list item, what is the “main” difference between using SPListItem.Update() and SPListItem.SystemUpdate()?
Using SystemUpdate() will not create a new version and will also retain timestamps. Using SystemUpdate alerts is not sent, and modified by is not changed to system account.
13) What is CAML, and why would you use it?
CAML stands for Collaborative Application Markup Language. CAML is an XML based language which provides data constructs that build up the SharePoint fields, view, and is used for table definition during site provisioning. CAML is responsible for rending data and the resulting HTML that is output to the user in SharePoint. CAML can be used for a variety of circumstances, overall is used to query, build and customize SharePoint based sites. A general use would be building a CAML query in a SharePoint WebPart in order to retrieve values from a SharePoint list.
14) What is a SharePoint Feature? What files are used to define a feature?
A SharePoint Feature is a functional component that can be activated and deactivate at various scopes throughout a SharePoint instances, such as at the farm, site collection, web, etc.
15) What are event receivers?
Event receivers are classes that inherit from the SpItemEventReciever or SPListEventReciever base class (both of which derive out of the abstract base class SPEventRecieverBase), and provide the option of responding to events as they occur within SharePoint, such as adding an item or deleting an item.
16) If you have an ItemUpdated or ItemUpdating event receiver and it causes an update to the item, how do you prevent another ItemUpdated and ItemUpdating event from being fired during your update?
Before performing your update, call DisableEventFiring(). After update, call EnableEventFiring().
17) How would you programmatically retrieve a list item?
You can use SPQuery to filter the list and SPSiteDataQuery used to join multiple list. Learn more on CrossListQueryCache, PortalSiteMapProvider.
- Microsoft Sharepoint persisting webpart property values
- Microsoft Sharepoint updating Author-Created By or Editor field programmatically
- Microsoft Sharepoint SystemUpdate and Update using object model
- Sharepoint OM, getting email ID from login user name
- Client Object Model and Linq to Sharepoint implementation
- List enhancements in SharePoint 2010
- Developer favorites SharePoint 2010 enhancements
- More about SharePoint Custom page and Application Page
- Infopath form to HTML using csharp
- Sharepoint 2010 features