Friday, April 26, 2013

Microsoft SharePoint SDK Interview Questions and Answers

This page contains the collection of Microsoft SharePoint SDK Interview Questions and Answers / Frequently Asked Questions (FAQs) under category Microsoft SharePoint. These questions are collected from various resources like informative websites, forums, blogs, discussion boards including MSDN and Wikipedia. These listed questions can surely help in preparing for Microsoft SharePoint SDK interview or job.


How can we debug share point application and timer jobs? 
1. Build Web Application and place the .dll into GAC
2. Reset IIS
3. In Visual Studio open the Debug menu and select Attach to Process
4. Select the Show processes from all users check box
5. Select W3W.exe and OSWTIMER.exe and click on Attach
6. Refresh sharepoint site and it will point to breakpoint

What does AllowUnsafeUpdates do ? 
If you are trying to modify Windows SharePoint Services data using code, you may need to allow unsafe updates on the Web site, without requiring a security validation. For this you need to set AllowUnsafeUpdates property to true.

What does RunWithElevatedPrivileges do? 
There are certain object models that calls another models that require site-administration privileges. To bypass access-denied error, we use RunWithElevatedPrivileges property when request is initiated by a nonprivileged user. We can successfully make calls into the object model by calling the RunWithElevatedPrivileges method provided by the SPSecurity class.

What does SPWeb.EnsureUser method do? 
Checks whether the specified login name belongs to a valid user of the Web site, and if the login name does not already exist, adds it to the Web site. e.g SPUser user = objWeb.EnsureUser("testuser");

What is the SPSite object, and 
The SPSite object represents a site collection (a top level site and all its subsites).

What is SPWeb object? 
The SPWeb object represents an instance SharePoint Web

What is the difference between SPSite and SPWeb objects? 
SPWeb object contains things like the actual content. A SPSite object contains the various subsites and the information regarding them.

What does a SPWebApplication object represent? 
The SPWebApplication objects represents a SharePoint Web Application, which essentially is an IIS virtual server. Using the class you can instigate high level operations, such as getting all the features of an entire Web Application instance, or doing high level creation operations like creating new Web Applications through code.

Would you use SPWebApplication to get information like the SMTP address of the SharePoint site? 
Yes, since this is a Web Application level setting. You would iterate through each SPWebApplication in the SPWebApplication collection, and then use the appropriate property calls (OutboundMailServiceInstance) in order to return settings regarding the mail service such as the SMTP address.

If I wanted to not allow people to delete documents from a document library, how would I go about it? 
You would on the ItemDeleting event set: properties.Cancel= true.

What base class do event receivers inherit from? 
Event receivers either inherit from the SPListEventReciever base class or the SPItemEventReciever base class, both which derive from the abstract base class SPEventReceiverBase.

What is the difference between an asynchronous and synchronous event receivers? 
An asynchronous event occurs after an action has taken place, and a synchronous event occurs before an action has take place. For example, an asynchronous event is ItemAdded, and its synchronous event is ItemAdding

What are event receivers? 
Event receivers are classes that provide the option of responding to events as they occur within SharePoint, such as adding an item or deleting an item.

What does partial trust mean for SharePoint Web Part developer? 
If an assembly is installed into the BIN directory, the code must be ensured that provides errorhandling in the event that required permissions are not available. Otherwise, unhandled securityexceptions may cause the Web Part to fail and may affect page rendering on the page where theWeb Part appears.

What is ServerUpdate() ? 
Any changes in the list, i.e. new addition or modification of an item. The operation is complete by calling the Update method. But if a List is set to maintain versions. and you are editing an item, but don't want to save it as a new version, then use the SystemUpdate() method instead and pass in 'false' as the parameter.

When modifying a list item, what is the "main" difference between using SPListItem.Update() and SPListItem.SystemUpdate()? 
SystemUpdate() will not create a new version of listitem and will also retain timestamps.

What is query.ViewAttributes and its use? 
If you use SPQuery on any SPList, it will bring back results from the current folder only. If you want to get results from all the folders in the list.. then you need to specify the scope of the query by the use of ViewAttributes.
e.g. query.ViewAttributes = "Scope=\"Recursive\"";

What Do you know about SharePoint Object Model? 
In Sharepoint Object model there are two Important namespaces, Microsoft.Office.Server and Microsoft.SharePoint . 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.

How Do you implement Impersonation in ShrePoint. 
By Using RunWithElevatedPrivileges method provided by SPSecurity class.

What is the performance impact of RunWithElevatedPrivileges? 
RunWithElevatedPrivileges creates a new thread with the App Pool's credentials and block your current thread until it finishes.

How can you use external Javascript and Css file in your WebPart? 
You can use javascript, Css or Image files placed in _Layouts or any other location by registering them on the webpart page.

Can you add a Custom aspx or WebApplication Page in SharePoint? 
Yes, Following modification are required in the Page to display it in SharePoint:
  • Add the references for various sharepoint assemblies on the Page
  • Wrap the Code in PlaceHolderMain contentPlaceholder, so that it gets displayed as a content page
  • Specify SharePoint Master in aspx and Code behind. You can switch the master page in code behind of the Page as well

When should you dispose SPWeb and SPSite objects? And 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.

How Do you bind a Drop-Down Listbox with a Column in SharePoint List ? 
There are two ways to do this:
1. You can get a datatable for all items in the list and add that table to a data set. Finally, specify the dataset table as datasource for dropdown listbox.
2. You can also use SPDatasource in your aspx or design page.

How do you return SharePoint List items using SharePoint web services? 
In order to retrieve list items from a SharePoint list through Web Services, you should use the lists.asmx web service by establishing a web reference in Visual Studio. The lists.asmx exposes the GetListItems method, which will allow the return of the full content of the list in an XML node. It will take parameters like the GUID of the name of the list you are querying against, the GUID of the view you are going to query, etc.

No comments:

Post a Comment