Sharepoint Interview Questions

1. What Do you know about SharePoint Object Model?
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.

The Chart Below illustrates some of the key classes contained in each of these namespaces, as well as to which functional area they belong.

Document Libraries (Microsoft.SharePoint)
SPDocumentLibrary , SPPictureLibrary

Business Data Catalog (Microsoft.Office.Server.ApplicationRegistry.Administration)
EntityCollection , ApplicationRegistry

Features (Microsoft.SharePoint)
SPFeatureDefinition, SPFeatureScope, SPElementDefinition, SPFeature, SPFeatureProperty

Sites (Microsoft.SharePoint)
SPSite, SPSiteAdministration, SPSiteCollection, SPWeb

Meetings (Microsoft.SharePoint.Meetings)
SPMeeting, MtgUtility

User Profiles (Microsoft.Office.Server.UserProfiles)
UserProfile, UserProfileManager

Solutions (Microsoft.SharePoint.Administration)
SPsolution, SPFeatureReceiver, SPSolutionCollection

Lists (Microsoft.SharePoint)
SPList, SPListItem, SPListItemCollection

2. Can you develop webparts and other SharePoint solutions at your local machine?

Ans.In order to run and debug sharePoint solutions, the project must reside on the server which has Windows sharePoint services installed. However, you can reference the Microsoft.SharePoint dll in your project at your local, but you won’t be able to run it.

 

3. How do you debug SharePoint Webparts?
Ans.
To debug SharePoint webpart (or any solution) you can simply drag and drop your complied .dll in GAC and recycle the app pool. You can also run upgrade solution command from stsadm.

4. How would you retrieve large number of Items form the list ?
Ans. If you have to retrieve a large number of Items and also need a better performance then you should use one of the methods below :

1. Using SPQuery

2. Using PortalSiteMapProvider Class

Lets see the examples for both the methods :

Our Query – Query to get all the Items in a list where Category is “Sp2007″

SPQuery -

// Get SiteColl
SPSite curSite = new SPSite(“http://myPortal”);

//Get Web Application
SPWeb curWeb = curSite.OpenWeb();

// Create a SPQuery Object
SPQuery curQry = new SPQuery();

// Write the query
curQry.Query = “<Where><Eq><FieldRef Name=’Category’/>
<Value Type=’Text’>SP2007 </Value></Eq></Where>”;

// Set the Row Limit
curQry.RowLimit = 100;

//Get the List
SPList curList = curWeb.Lists(new Guid(“myListGUID”));

//Get the Items using Query
SPListItemCollection curItems = curList.GetItems(curQry);

// Enumerate the resulting items
foreach (SPListItem curItem in curItems)
{

string ResultItemTitle = curItem["Title"].ToString();

}

PortalSiteMapProvider class -

The 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.

// Get Current Web
SPWeb curWeb = SPControl.GetContextWeb(HttpContext.Current);

//Create the Query
SPQuery curQry = new SPQuery();
curQry.Query = “<Where><Eq><FieldRef Name=\’Category\’/><Value Type=\’Text\’>SP2007</Value></Eq></Where>”;

// Get Portal Map Provider
PortalSiteMapProvider ps = PortalSiteMapProvider.WebSiteMapProvider;

PortalWebSiteMapNode pNode = TryCast (ps.FindSiteMapNode (curWeb.ServerRelativeUrl), PortalWebSiteMapNode);

// Get the items
pItems = ps.GetCachedListItemsByQuery(pNode, “myListName_NotID”, curQry, curWeb);

// Enumerate all resulting Items
foreach (PortalListItemSiteMapNode curItem in pItems)
{
string ResultItemTitle = curItem["Title"].ToString();
}

5. What is impersonation, and when would you use impersonation?

Ans. Impersonation can basically provide the functionality of executing something in the context of a different identity, for example assigning an account to users with anonymous access. You would use impersonation in order to access resources on behalf of the user with a different account, that normally, that wouldn’t be able to access or execute something.

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

The SPSecurity class provides a method (RunWithElevatedPrivileges) that allows you to run a subset of code in the context of an account with higher privileges than the current user.
The premise is that you wrap the RunWithElevatedPrivileges method around your code. And also In certain circumstances, such as when working with Web forms, you may also need to set the AllowSafeUpdates method to true to temporarily turn off security validation within your code. If you use this technique, it is imperative that you set the AllowSafeUpdates method back to false to avoid any potential security risks.

Code example

{
SPSite mySite = SPContext.Current.Site;
SPWeb myWeb = mySite.OpenWeb();

//Using RunWithElevatedPrivileges

SPSecurity.RunWithElevatedPrivileges(delegate()
{
// Get references to the site collection and site for the current context.
// The using statement makes sures these references are disposed properly.

using (SPSite siteCollection = new SPSite(mySite.ID))
{

using (SPWeb web = siteCollection.OpenWeb(myWeb.ID))
{

web.AllowUnsafeUpdates = true;

try
{
//Your code
}

web.AllowUnsafeUpdates = false;

//siteCollection = null;
//web = null;

}

7. What is the performance impact of RunWithElevatedPrivileges?
Ans. RunWithElevatedPrivileges creates a new thread with the App Pool’s credentials, blocking your current thread until it finishes.


8. How will you add Code behind to a Custom Applictaion Page or a Layout Page in SharePoint?
Ans.
You do not deploy a code behind file with your custom Layouts page. Instead, you can have the page inherit from the complied dll of the solution to access the code behind.

9. What is the difference between a Site Definition and a Site Template?
Ans. Site Definitions are stored on the hard drive of the SharePoint front end servers. They are used by the SharePoint application to generate the sites users can create. Site Templates are created by users as a copy of a site they have configured and modified so that they do not have to recreate lists, libraries, views and columns every time they need a new instance of a site.

10. Why do you use Feature Receivers?
Ans.
Feature Receivers are used to execute any code on Activation\Deactivation of a Feature. You can use it for various purposes.

11. Can you give a example where feature receivers are used.
Ans
. You can use it to assign an event receiver feature to a specific type of list or can write a code in a feature receivers Deactivate method to remove a webpart from webpart gallery.

12. Where do you deploy the additional files used in your webpart, like css or javascript files, and how do you use them in your WebPart?
Ans.
You can deploy the css or javascript files in _layouts folder in SharePoint’s 12 hive. To use them in your webpart, you need to first register them to your webpart page and then specify a virtual path for the file for e.g. _layouts\MyCSS.css .See example below

Button Testbutton;
Image img;
string imagePath;

// Referring External Javascript
ClientScriptManager cs = Page.ClientScript;
// Include the required javascript file.
if (!cs.IsClientScriptIncludeRegistered(“jsfile”))
cs.RegisterClientScriptInclude(this.GetType(), “jsfile”, “/_wpresources/MyWP/1.0.0.0_9f4da00116c38ec5/jsfile.js”);

Test :
Testbutton= new Button();
Testbutton.Text = “Click me”;
Testbutton.OnClientClick = “jsfile_Function()”; // specify function name here
this.Controls.Add(Testbutton);

// Refering External CSS
Microsoft.SharePoint.WebControls.CssLink cssLink = new Microsoft.SharePoint.WebControls.CssLink();
cssLink.DefaultUrl = “/_wpresources/MyWP/1.0.0.0_9f4da00116c38ec5/styles.css”;
this.Page.Header.Controls.Add(cssLink);

// Using External Image
imagePath = “/_wpresources/MyWP/1.0.0.0_9f4da00116c38ec5/Image.jpg”;
img.ImageUrl = imagePath;
img.ID = “image1″;

this.Controls.Add(mybutton);
this.Controls.Add(img);
13: When should you dispose SPWeb and SPSite objects?
Ans. According to the best Practices you should always dispose them if you have created them in your code. You can dispose them in Finally block or you can use the “Using” clause, so that they gets disposed when not required. If you are using SPContext then you need not dispose the spsite or spweb objects.

14. 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.
15. What is the main difference between using SPListItem.Update() and SPListItem.SystemUpdate()?

Ans. Using SystemUpdate() will not create a new version and will also retain timestamps.

16. 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 colletcion. The data is extracted on the basis of the query you write and is
returened as a Datatable. You can also specify the GUID for the lists\libraries you want to query against.

17. How do you create a Custom action for an item in a list ?
Ans. This can be done by adding a new feature into SharePoint. You would need to use customaction tag in your elements.xml file and will have to set various properties like imageurl or UrlAction for your customaction. You can later add this feature into sharepoint using stsadm install feature command.

18. How would you bind this CustomAction to a specific list ?
Ans. To do this you can either create a new list type(again a feature) and use the listtype number for the new list in your RegistrationType property of the Customaction. The CustomAction will then show up only for the items of this list type. or You can create a new content type and then use that content type’s id in your cutsomaction to bind the custom action to items of just that content type. Add the new content type to the list where you need this customaction.

19. How will you deploy an existing asp.net webapplication or website in SharePoint?
Ans.
You would need to wrap the web application in a solution package in order to deploy it in 12 hive or say ShraePoint. It is recommended to create a feature first, and then wrap everything in a Solution package.

20. How will you cancel a deployment from central admin -> solution managment, if its stuck at “deploying” or “Error”.
Ans.
You can either try to force execute timer jobs using execadmsvcjobs command or can cancel the dpeloyment using stsadm command stsadm –o cancaldeployment –id {GUID} command. The Id here would be GUID of the timer or deployment job. You can get the Id from stsadm enumdeployment command. This will display all the deployments which are process or are stuck with Error.

21. How do make an existing non-publishing site Publishing?
Ans.
You can simply activate the SharePoint Publishing Feature for the Site, you want to make publishing.

22. Can you name some of the tools used for SharePoint Administration?
Ans.
Axceler’s ControlPoint, Nintex Workflow 2007, DocAve

 

23. What are Application Pages in SharePoint?
Ans.
Unlike site pages (for example, default.aspx), a custom application page is deployed once per Web server and cannot be customized on a site-by-site basis. Application pages are based in the virtual _layouts directory. In addition, they are compiled into a single assembly DLL.
A good example of an Application Page is the default Site Settings page: every site has one, and it’s not customizable on a per site basis (although the contents can be different for sites).
With application pages, you can also add inline code. With site pages, you cannot add inline code.

24. What is Authentication and Authorization?
Ans . An authentication system is how you identify yourself to the computer. The goal behind an authentication system is to verify that the user is actually who they say they are.
Once the system knows who the user is through authentication, authorization is how the system decides what the user can do.

25. How do you deploy a User Control in SharePoint ?
Ans. You deploy your User Control either by a Custom webpart, which will simply load the control on the page or can use tools like SmartPart, which is again a webpart to load user control on the page. User Control can be deployed using a custom solution package for the webapplication or you can also the control in the webpart solution package so that it gets deployed in _controlstemplate folder.

26. Which is faster a WebPart or a User Control?
Ans. A WebPart renders faster than a User Control. A User Control in SharePoint is usually loaded by a webpart which adds an overhead. User Controls however, gives you an Interface to add controls and styles.

27. What SharePoint Databases are Created during the standard Install?
Ans. During standard install, the following databases are created :

SharePoint_AdminContent
SharePoint_Config
WWS_Search_SERVERNAME%_%GUID_3%
SharedServicesContent_%GUID_4%
SharedServices1_DB_%GUID_5%
SharedServices1_Search_DB_%
GUID_6%WSS_Content_%GUID_7%

28. What are content types?
Ans. A content type is a flexible and reusable WSS type definition (or we can a template) that defines the columns and behavior for an item in a list or a document in a document library. For example, you can create a content type for a leave approval document with a unique set of columns, an event handler, and its own document template and attach it with document library/libraries.

29. Can a content type have receivers associated with it?
Ans.
Yes, a content type can have an event receiver associated with it, either inheriting from the SPListEventReciever base class for list level events, or inheriting from the SPItemEventReciever base class. Whenever the content type is instantiated, it will be subject to the event receivers that are associated with it.

30. What two files are typically (this is kept generally) included when developing a content type, and what is the purpose of each?

Ans. There is generally the main content type file that holds things like the content type ID, name, group, description, and version. There is also the ContentType.Fields file which contains the fields to include in the content type that has the ID, Type, Name, DisplayName, StaticName, Hidden, Required, and Sealed elements. They are related by the FieldRefs element in the main content type file.

31. What is an ancestral type and what does it have to do with content types?

Ans. An ancestral type is the base type that the content type is deriving from, such as Document (0×0101). The ancestral type will define the metadata fields that are included with the custom content type.

32. Can a list definition be derived from a custom content type?

Ans. 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.

33. Can you add a Cutsom Http Handler in SharePoint ?
Ans.
Yes, a Custom httphandler can be deployed in _layouts folder in SharePoint. Also, we need to be register the handler in the webapp’s webconfig file.

34. While creating a Web part, which is the ideal location to Initialize my new controls?
Ans. Override the CreateChildControls method to include your new controls. You can control the exact rendering of your controls by calling the .Render method in the web parts Render method.

35. How do you return SharePoint List items using SharePoint web services?
Ans. 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.

36. How Do you deploy Files in 12 hive when using wspbuilder or vsewss?
Ans.Typically, you can add these files in the 12 hive folder structure in your project. In Vsewss however, you will have to create this structure manually.

37. What files gets created on a file system, when a Site collection is created ?
Ans.
Windows SharePoint Services does not create any files or folders on the file system when the site collection or sites are created; everything is created in the content database. The Pages for the site collection are created as instances in the content database. These instances refer to the actual file on the file system.

38. What are Customized(unghosted) and Uncustomized(ghosted) Files in SharePoint ?
Ans.
There are two types of Pages in SharePoint; site pages (also known as content pages) and application pages.

Uncustomized :

When you create a new SharePoint site in a site collection, Windows SharePoint Services provisions instances of files into the content database that resides on the file system. That means if you create a new Site “xyz” of type Team Site(or Team sIte Definition), an instance of the Team Site Definition( Which resides on the File System), i.e. “xyz” gets created in the Content database. So, When ASP.NET receives a request for the file, it first finds the file in the content database. This entry in the content database tells ASP.NET that the file is actually based on a file on the file system and therefore, ASP.NET retrieves the source of the file on the file system when it constructs the page.

Customized :

A customized file is one in which the source of the file lives exclusively in the site collection’s content database. This happens When you modify the file in any way through the SharePoint API, or by SharePoint Designer 2007,which uses the SharePoint API via RPC and Web service calls to change files in sites. So, When the file is requested, ASP.NET first finds the file in the content database. The entry in the database tells ASP.NET whether the file is customized or uncustomized. If it is customized, it contains the source of the file, which is used by ASP.NET in the page contraction phase.

 

39. What is a SharePoint site definition

Ans. SharePoint site definitions are the core set of functionality from which SharePoint site are built from, building from the SiteTemplates directory in the SharePoint 12 hive. Site definitions allow several sites to inherit from a core set of files on the file system, although appear to have unique pages, thereby increasing performance and allowing changes that happen to a site propagate to all sites that inherit from a site definition.

40. What are event receivers?
Ans.
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.

41. When would you use an event receiver?
Ans.
Since event receivers respond to events, you could use a receiver for something as simple as canceling an action, such as deleting a document library by using the Cancel property. This would essentially prevent users from deleting any documents if you wanted to maintain retention of stored data.

42. If I wanted to restrict the deletion of the documents from a document library, how would I go about it?
Ans.
You would create a event receiver for that list/library and implement the ItemDeleting method. Simply, set: properties.Cancel= true and display a friendly message using Properties.Message(“How can u delete this… Its not your stuff!”);
43. What is the difference between an asynchronous and synchronous event receivers?
Ans.
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 sister synchronous event is ItemAdding

 

44. What base class do event receivers inherit from?

Ans. Event receivers either inherit from the SPListEventReciever base class or the SPItemEventReciever base class, both which derive from the abstract base class SPEventReceiverBase.

45. How could you append a string to the title of a site when it is provisioned?

Ans. In the OnActivated event:

PLAIN TEXT

C#:

  1. SPWeb site = siteCollection.RootWeb;
  2. site.Title += “interview”;
  3. site.Update();

46. Can an event receiver be deployed through a SharePoint feature?

Ans. Yes.

47. How do you Increase trust level for a single WebPart in the WebConfig file.
Ans.
To list a Web Part with Full Permissions within your Web Application while still retaining a WSS_Minimal permission set for all other Web Parts, You need to create a Custom policy file. This file will be then referenced in SharePoint Web.config file and will allow your specific webpart to be of Full trust.
Steps :
1. Make a copy of the WSS_Minimal.Config file from the 12\Config folder and paste it into the same folder renaming it to Custom_WSS_Minimal.Config. Now, edit the Custom_WSS_Minimal.Config file using NotePad. Obtain the Public Key Token for the Web Part assembly that you want to deploy, using the following command: sn –Tp filename.dll. Create a new entry in your Custom_WSS_Minimal.Config file for your WebPart. Save the File.
Finally, Create a new TrustLevel element for your config file in the Web.Config called Custom_WSS_Minimal that points to your custom file in the 12\config folder. Recycle the Application Pool and You’re Done.

48. How does Windows SharePoint Services help render the Webapplictaion in ShrePoint?
Ans.When a new web applictaion is created via Central Admin, Windows SharePoint Services creates a new Web application in IIS. Then the WSS, loads the custom HTTP application and replaces all installed HTTP handlers and modules with Windows SharePoint Services–specific ones. These handlers and modules essentially tell IIS to route all file requests through the ASP.NET 2.0 pipeline. This is because most files in a SharePoint site are stored in a Microsoft SQL Server database.

49. How would you pass user credentials while using SharePoint WebService from your Web Part or application.
Ans.
The web service needs credentials to be set before making calls.

Examples:

listService.UseDefaultCredentials = true; // use currently logged on user

listService.Credentials = new System.Net.NetworkCredential(“user”, “pass”, “domain”); // use specified user

50. How would you remove a webapart from the WebPart gallery? Does it get removed with Webpart retraction?
Ans.
No, Webpart does not get removed from the WebPart gallery on retraction. You can write a feature receiver on Featuredeactivating method to remove the empty webpart from the gallery.

51. What is a SharePoint Feature? Features are installed at what scope
Ans. A SharePoint Feature is a functional component that can be activated and deactivate at various scopes throughout a SharePoint instances, scope of which are defined as
1. Farm level 2. Web Application level 3. Site level 4. Web level
Features have their own receiver architecture, which allow you to trap events such as when a feature is Installing, Uninstalling, Activated, or Deactivated.

 

52. What files are used to define a feature?

Ans. The two files that are used to define a feature are the feature.xml and manifest file. The feature XML file defines the actual feature and will make SharePoint aware of the installed feature. The manifest file contains details about the feature such as functionality.

53. How the introduction of features has changed the concept of site definitions ?

Ans. SharePoint features are important when understanding the architecture of site definitions, since the ONET.XML file has been vastly truncated since it has several feature stapled on it.

54. What types of SharePoint assets can be deployed with a SharePoint feature?

Ans. Features can do a lot. For example, you could deploy Simple site customizations,Custom site navigation,WebParts,pages,list types,list instances,event handlers,workflows,custom actions

55. What type of components can be created or deployed as a feature?
Ans.
We can create menu commands, Custom Actions,page templates, page instances, list definitions, list instances,event handlers,webparts and workflows as feature.

56. How Do you bind a Drop-Down Listbox with a Column in SharePoint List ?
Ans.
Method 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.

Method 2 : You can also use SPDatasource in your aspx or design page.

57. How Does SharePoint work?
Ans.
The browser sends a DAV packet to IIS asking to perform a document check in. PKMDASL.DLL, an ISAPI DLL, parses the packet and sees that it has the proprietary INVOKE command. Because of the existence of this command, the packet is passed off to msdmserv.exe, who in turn processes the packet and uses EXOLEDB to access the WSS, perform the operation and send the results back to the user in the form of XML.

58. What is CAML, and why would you use it?

Ans. 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.

59. Can you display\add a Custom aspx or WebApplication Page in SharePoint Context ?

Ans.You need to make some modification in the aspx file to display it in SharePoint Context. Firstly, add the references for various sharepoint assemblies on the Page. Then wrap the Code in PlaceHolderMain contentPlaceholder, so that it gets displayed as a content page. Lastly, add a reference to SharePoint Master Page in aspx file and swicth it in Code behind if needed.

60. What are the two base classes a WebPart you are going to use within SharePoint 2007 can inherit from?

Ans. There are two base classes that a WebPart which is going to be consumed by SharePoint can inherit from, either the SharePoint WebPart Base class or the ASP.NET 2.0 WebPart base class. 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 from System.Web.UI.WebControls.WebParts.WebPart. It is considered good practice to use the ASP.NET WebPart base class since the old base class is meant for backwards compatibility with previous version of SharePoint, however there are four exception when it is better to leverage functionality from the SharePoint WebPart base class:

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

61. What are the differences between the two base classes and what are the inherit benefits of using one over another?

Ans. The difference is the Microsoft.SharePoint.WebPartPages.WebPart base class is meant for backward compatibility with previous versions of SharePoint. The benefit of using the SharePoint WebPart base class is it supported:

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

ASP.NET 2.0 WebParts are generally considered better to use because SharePoint is built upon the ASP.NET 2.0 web architecture. Inheriting from the ASP.NET 2.0 base class offers you features that inherit to ASP.NET 2.0, such as embedding resources as opposed to use ClassResources for deployment of said types.

62. What is the GAC?

Ans. The GAC stands for the global assembly cache. It is the machine wide code cache which will give custom binaries place into the full trust code group for SharePoint. Certain SharePoint assets, such as Feature Receivers need full trust to run correctly, and therefore are put into the GAC. You should always try to avoid deployment to the GAC as much as possible since it will possibly allow development code to do more than it was intended to do.

63. What is strong naming (signing) a WebPart assembly file mean?

Ans. Signing an assembly with a strong name (a.k.a strong naming) uses a cryptographic key pair that gives a unique identity to a component that is being built. This identity can then be referred throughout the rest of the environment. In order to install assemblies into the GAC, they must be strongly named. After signing, the binary will have a public key token identifier which can be use to register the component in various other places on the server.

64. What are safe controls, and what type of information, is placed in that element in a SharePoint web.config file?

Ans. 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.

In the generic safe control entry (this is general, there could be more), there is generally the Assembly name, the namespace, the public key token numeric, the typename, and the safe declaration (whether it is safe or not). There are other optional elements.

65. What is the CreateChildControls() method? How can you use it to do something simple like displaying a Label control?

Ans. 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. Then the add method of the control class will add the control to the controls collection. In the relevant WebPart render method, the EnsureChildControls method can be called (or set to false if no child controls should be called) to ensure that the CreateChildControls method is run. When using CreateChildControls it implies that your WebPart contains a composition of child controls.

In order to create something like a label control in Create, you would create a new label control using the new keyword, set the various properties of the control like Visible=True and ForeColor = Color.Red, and then use Controls.Add(myLabelControl) to add the control to the controls collection. Then you can declare EnsureChildControls in the Render method of the WebPart.

66. What does the RenderContents method do in an ASP.NET 2.0 WebPart?

Ans. 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.

67. Difference between CreateChildControls and the RenderContents method.

Ans. The CreateChildControls method is used to add controls to the WebPart, and the RenderContents method is used to tell the page framework how to render the control into HTML to display on a page.

68. What is the WebPartManager sealed class? What is its purpose?

Ans. 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. It is known as the “the central class of the Web Part Control Set.”

69. how many WebPartManager controls should be on a page?

Ans. In order to have WebParts on a page there has to be just one WebPartManager control to manage all the WebParts on the page.

70. What is a SPSite and SPWeb object, and what is the difference between each of the objects?

Ans. 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.

71.  How would you go about getting a reference to a site?

Ans.

PLAIN TEXT

C#:

  1. oSPSite = new  SPSite(“http:/server”);
  2.  
  3. oSPWeb = oSPSite.OpenWeb();

72. What does a SPWebApplication object represent?

Ans. 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.

73. Would you use SPWebApplication to get information like the SMTP address of the SharePoint site?

Ans. 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.

74.  Are there other ways to send emails from SharePoint?

Ans. Yes, there is. You can use the SendMail method from the SPutility class to send simple emails, however it is not as robust as using the System.Net.Mail functionality since it doesn’t allow things like setting priorities on the email.

75. How do you connect (reference) to a SharePoint list, and how do you insert a new List Item?

Ans.

PLAIN TEXT

C#:

  1. using(SPSite mySite = new SPSite(“yourserver”))
  2. {
  3. using(SPWeb myWeb = mySite.OpenWeb())
  4. {
  5. SPList interviewList = myWeb.Lists["listtoinsert"];
  6. SPListItem newItem = interviewList.Items.Add();
  7.  
  8. newItem["interview"] = “interview”;
  9. newItem.Update();
  10. }
  11. }

76. How would you loop using SPList through all SharePont List items, assuming you know the name (in a string value) of the list you want to iterate through, and already have all the site code written?

Ans.

PLAIN TEXT

C#:

  1. SPList interviewList = myWeb.Lists["listtoiterate"];
  2. foreach (SPListItem interview  in interviewList)
  3. {
  4. // Do Something
  5. }

77. When retrieving List items using SharePoint Web Services, how do you specify explicit credentials to be passed to access the list items?

In order to specify explicit credentials with a Web Service, you generally instantiate the web service, and then using the credentials properties of the Web Service object you use the System.Net.NetworkCredential class to specify the username, password, and domain that you wish to pass when making the web service call and operations.

78. When you should state the credentials in code?

Ans. You must state the credentials you are going to pass to the web service before you call any of the methods of the web service, otherwise the call will fail.

79. What is the IDesignTimeHtmlProvider interface, and when can you use it in WebParts?

Ans. The IDesignTimeHtmlProvider interface uses the function GetDesignTimeHtml() which can contain your relevant render methods. It was helpful to use in 2003 since it allowed your WebPart to have a preview while a page was edited in FrontPage with the Webpart on it, because the GetDesignTimeHtml() method contains the HTML for the designer to render.

80. What are WebPart properties, and what are some of the attributes you see when declaring WebPart properties in code?

Ans. WebPart properties are just like ASP.NET control properties, they are used to interact with and specify attributes that should be applied to a WebPart by a user. Some of the attributes you see with ASP.NET 2.0 properties are WebDescription, WebDisplayName, Category, Personalizable, and WebBrowsable. Although most of these properties come from the System.Web.UI.WebControls.WebParts class, ones like Category come out of System.ComponentModel namespace.

81.  Why are properties important in WebPart development, and how have you exploited them in past development projects? What must each custom property have?

Ans. Properties are important because WebParts allow levels of personalization for each user. WebPart properties make it possible for a user to interact, adjust, and increase overall experience value with the programmatic assets that you develop without having the need to use an external editor or right any code. A very simple example of exploiting a property would be something like allowing the user to change the text on the WebPart design interface so that they can display whatever string of text they desire.

Each custom property that you have must have the appropriate get and set accessor methods.

82. What are ClassResources? How do you reference and deploy resources with an ASP.NET 2.0 WebPart?

Ans. ClassResources are used when inheriting from the SharePoint.WebPart.WebPartPages.WebPart base class, and are defined in the SharePoint solution file as things that should be stored in the wpresources directory on the server. It is a helpful directory to use in order to deploy custom images. In ASP.NET 2.0, typically things such as images are referenced by embedding them as resources within an assembly. The good part about ClassResources is they can help to eliminate recompiles to change small interface adjustments or alterations to external JavaScript files.

83.  What is a SharePoint Solution File? How does it differ from WebPart .cab files in legacy development? What does it contain?

Ans. A SharePoint solution file is essentially a .cabinet file with all a developers ustom componets suffixed with a .wsp extension that aids in deployment. The big difference with SharePoint solution files is is that a solution:

allows deployment to all WFE’s in a farm

is highly manageable from the interface allowing deployment, retraction, and versioning

Can package all types of assets like site definitions, feature definitions (and associated components), Webparts, etc.

Can provide Code Access Security provisioning to avoid GAC deployments

84. What is a .ddf file and what does it have to do with SharePoint Solution creation?

Ans.  .ddf file is a data directive file and is used when building the SharePoint solution bundle specifying the source files and their destination locations. The important thing for someone to understand is that the .ddf file will be passed as a parameter to the MAKECAB utility to orchestrate construction of the SharePoint solution fiel.

85. What file does a SharePoint solution package use to orchestrate (describe) its packaged contents?

Ans. The solution Manifest.XML file.

86. What deployment mechanism can you use to instigate Code Access Security attributes for your WebParts?

Ans. SharePoint solution files can add in order to handle code access security deployment issues. This is done in the element in the SharePoint solution manifest.XML, which makes it easier to get assemblies the appropriate permissions in order to operate in the bin directory of the web application.

87. When creating a list definition, how can you create an instance of the list?

You can create a new instance of a list by creating an instance.XML file.

88. What is a Field Control?

Field controls are simple ASP.NET 2.0 server controls that provide the basic field functionality of SharePoint. They provide basic general functionality such as displaying or editing list data as it appears on SharePoint list pages.

89. What base class does custom Field Controls inherit from?

This varies. Generally, custom field controls inherit from the Microsoft.SharePoint.WebControls.BaseFieldControl namespace, but you can inherit from the default field controls.

90. How does one deploy new SharePoint site definitions so that they are made aware to the SharePoint system?

The best way to deploy site definitions in the SharePoint 2007 framework is to use a SharePoint solution file, so that the new site definition is automatically populated to all WFE’s in the SharePoint farm.

About these ads
Comments
One Response to “Sharepoint Interview Questions”
  1. here i have collected lots of topics related to:

    Microsoft SharePoint Interview Questions and Answers

    kindly have a look this would help you a lot

    Regards,

    Akaas Developer

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 27 other followers

%d bloggers like this: