Interview Questions Of SharePoint 2007 Object Model

Q. What are the main namespaces in SharePoint 2007 ?

Ans. In Sharepoint Object model there are two Important namespaces. The Microsoft.Office.Server namespace is the root namespace of all Office Server objects and Microsoft.SharePoint is the root namespace for all WSS objects.

Q. How Do you create custom column in Sharepoint object model ?

Ans. To create custom filed types you need to follow the below steps :
1. Create a Field Type Definition
2. Create a Field Class
3. Create a Rendering Control Class
4. Create One or More Rendering Templates
5. Create a Field Value Type
6. Create an Editing Control

Q. How do I use and deploy code behind files with my custom pages in SharePoint ?

Ans. You do not deploy code behind files in along with your custom aspx or layouts page Instead, you can just have the aspx page inherit from the compiled .dll of the project containing that code file.

Q. How can you get the filtered items from a  SharePoint list programatically?

Ans. You can either use SPQuery with the where condition or you can set a up a filtered view in the list itself and then access the view in your solution using SPView class.

Q. What will you do for fast and efficient retrieval of items from sharepoint lists ?

Ans. You can use either SPquery object from SPquery class or you can use PortalSiteMapProvider class. PortalSiteMapProvider class includes a method called GetCachedListItemsByQuery that retrieves data from a list based on an SPQuery object that is provided as a parameter to the method call. The method then looks in its cache to see if the items already exist. If they do, the method returns the cached results, and if not, it queries the list, stores the results in cache and returns them from the method call.

Q. What are Activation Dependencies in SharePoint fetaures ?


A Feature activation dependency expresses a requirement in the relationship between two Features. You generally use activation dependencies for two purposes:
1. To specify that your feature should not be activated unless another feature gets activated. It means your feature activation is dependent of the activation of some other feature. To implement this all you need to do is add a <ActivationDependencies> tag in your feature.xml file and add a ActivationDependency under it. ActivationDependency however needs FeatureId i.e. the guid of the parent feature  on whom your feature is dependent.
2. For Feature grouping concepts. That means when one Feature is activated, other Features can also be activated.

Q. When do you use SPSiteDataQuery ?

Ans. You can use SPSiteDataQuery when you need to extract data from more than one list\library in your site collection. The data is extracted on the basis of the query you write and is returned as a Datatable.

Q. Can you specify a particular list for SPSiteDataQuery ?

Ans. You can also specify the GUID for the lists\libraries you want to query against in  lists tag.

Q. What are the best practices for SharePoint development.

Ans. Some of the best practices are:

1. You should always dispose SPsite and SPWeb objects, once you refer them in your code. Using the "Using" clause is recommended.

2. Use RunwithelevatePrivilages to avoid errors for end users.

3. Try writing your errors to SharePoint error logs (ULS Logs). Since it's a bad idea to fill-up event log for your production environment.

4. Use SPQuery instead of foreach loop while retrieving Items from the list.

5. Deploy additional files used in your webpart to 12 hive. Use your solution package to drop the files in 12 hive. Also, make sure that all the references (for e.g. Css or .js files) get removed when the solution is retracted.

Q. How should I deploy a webpart, a master page and a layouts page in one solution package ?

Ans.Create different features file for each component  and add Modules for them in their elements file. all features can be added in one solution package.