Raghu's SharePoint Corner: May 2009

My blog has moved!

You will be automatically redirected to the new address. If that does not occur, visit
http://www.sharepointcolumn.com
and update your bookmarks.

May 26, 2009

New Version Of AjaxControlToolKit

Recently they have announced the newer version of Ajax Control Tool Kit. The new version of Ajax control toolkit can be used only on .net framework 3.5 and visual studio 2008. If you want to use visual studio 2005 then you need to user the previous version of Ajax Control Tool Kit

They have added three new Controls to the tool kit

1. HTMLEditor:This is a rich text editor, so people using third party tools can now use this control, i dont think spell check is integrated in this editor. You can see the live demo here


2. Combo Box: This a is a great control, was waiting for this control from long time, its a text box and a combo box control, where in you can type in the comobox..cool isnt it. you can see the live demo here

3. Color Picker: A new color picker control, fed up of using java script for color picker or any third party tool, you can try ajax control tool kit color picker, You can see the live demo here

Make sure that you are using Visual Studio 2008 and .Net Framework 3.5 to use the newer version of Ajax Control Tool Kit. You can download the tool kit from below

Download New Ajax Control Tool Kit

May 19, 2009

Sharepoint 2007 Limitations

Site object Guidelines for acceptable performance performance degrades if the below specified limitations exceed.

1. Site collection: 50,000 per Web application Total farm throughput degrades as the number of site collections increases.

2. Web site: 250,000 per site collection You can create a very large total number of Web sites by nesting the subsites. For example, 100 sites, each with 1000 subsites, is 100,000 Web sites. The maximum recommended number of sites and subsites is 125 sites with 2,000 subsites each, for a total of 250,000 sites.

3. Subsite: 2,000 per Web site The interface for enumerating subsites of a given Web site does not perform well as the number of subsites surpasses 2,000.

4. Document: 5 million per library You can create very large document libraries by nesting folders, using standard views and site hierarchy. This value may vary depending on how documents and folders are organized, and by the type and size of documents stored.

5. Item: 2,000 per view Testing indicates a reduction in performance beyond two thousand items. Using indexing on a flat folder view can improve performance.

6. Document file size 50MB (2GB max*): File save performance is proportional to the size of the file. The default maximum is 50 MB. This maximum is enforced by the system, but you can change it to any value up to 2 GB.

7. List: 2,000 per Web site Testing indicates a reduction in list view performance beyond two thousand entries.

8. Field type: 256 per list This is not a hard limit, but you might experience list view performance degradation as the number of field types in a list increases.

9. Column: 2,000 per document library 4,096 per list This is not a hard limit, but you might experience library and list view performance degradation as the number of columns in a document library or list increases.

10. Web Part: 50 per page This figure is an estimate based on simple Web Parts. The complexity of the Web Parts dictates how many Web Parts can be used on a page before performance is affected.

Increase FileUpload Size in Sharepoint

This post deals with how to increase the file upload size in a sharepoint (i.e either in document library or as list attachment). Even after increase in the document upload size you have to increase the time out size also. Given below are the steps to increase the file upload size and how to increase the time out exception.

Increase the maximum upload size

1. Click Start, point to All Programs, point to Administrative Tools, and then click SharePoint Central Administration.
2. Under Virtual Server Configuration, click Configure virtual server settings. On the Virtual Server List page, click the virtual server that you want to change.
On the Virtual Server Settings page, under Virtual Server Management, click Virtual server general settings.
3. Under Maximum upload size, type the maximum file size in megabytes that you want, and then click OK. You can specify a maximum file size up to 2,047 megabytes.
Back to the top

or
1. Click Start, point to All Programs, point to Administrative Tools, and then click SharePoint Central Administration.
2. Click on Application Management tab, click Web Application General Settings under Sharepoint Web Application Management.
3. Maximum Upload size is 50 you can increase this upload size according to your requirement but the maz size is 2GB

Add the executionTimeout value

1. Use Notepad to open the Web.config file.

2. By default, this file is in the following location:
Program Files\Common Files\Microsoft Shared\Web server extensions\12\TEMPLATE\LAYOUTS
3. Add the executionTimeout value that you want. For example, replace the value as follows.
Existing code


<location path="upload.aspx">
<system.web>
<httpRuntime maxRequestLength="2097151" />
</system.web>
</location>


Replacement code


<location path="upload.aspx">
<system.web>
<httpRuntime executionTimeout="999999" maxRequestLength="2097151" />
</system.web>
</location>


4. After you change the file, click Save on the File menu.
5. Use Notepad to open the Web application Web.config file. By default, this file is in the following folder: C:\Inetpub\wwwroot\wss\VirtualDirectories\VirtualDirectoryFolder
6.Change the following line in the file.
Existing line


<httpRuntime maxRequestLength="51200" />


Replacement line


<httpRuntime executionTimeout="999999" maxRequestLength="51200" />


7. After you change the file save and exit.

May 18, 2009

Integrating Reporting Services Native Mode in SharePoint

Today in this post i will be talkign about integation of Reporting Services with sharepoint in native mode. There are two possible ways to integrate Reporting Services in Sharepoint

1. Native Mode

When you configure Reporting Service to run in Native Mode, reports are displayed using an HTML Viewer interface that is built into Reporting Services. The HTML Viewer provides all of the basic functionality users required to view, navigate, and print reports. It also provides many Url parameter options to control report parameters and rendering rendering – options that are not available when viewing reports using the RSViewerPage page and the Report Viewer Web Part.

Yes, You Can Use the HTML Viewer in SharePoint Integrated Mode
When you configure Reporting Services to run in SharePoint Integrated Mode, it’s your choice. You can use either the RSViewerPage or the HTMLViewer to view your reports. The look and feel of the HTML Viewer isn’t as nice as the RSViewerPage interface, but it’s equally functional, and it provides a lot of Url options that can’t be duplicated using the RSViewerPage.

In the HTML Viewer, the report parameter options are displayed at the top of the page (the Report Viewer Web Part shows them on the right-hand side of the report). You can use the HTML Viewer user interface to view the report, change parameters, collapse parameters, zoom, print, export, etc. When you use the HTML Viewer to view your report, you lose the SharePoint UI look and feel, cookie crumb navigation, MySite and MyLinks integration, and Report Builder and Subscriptions integration. You gain the Url options we’ll be discussing later in this post – options that are not supported by the RSViewerPage or the Report Viewer Web Part.


2. Sharepoint Integrated Mode.

In Sharepoint Integrated Mode the reports are dispayed using the RSViewerPage.aspx page thats is located at /_layouts/ReportViewer/RSViewerPage.aspx. This page provides an a SharePoint look and feel, and integrated navigation back to your SharePoint site. It leverages the Report Viewer Web Part to display the report. The Report Viewer Web Part has some very nice features:

An integrated SharePoint look/feel
Cookie crumb navigation back to your site, MySite, and MyLinks
A collapsible parameter panel to the right of the report
1. A nice toolbar with zoom and page navigation
2. An Actions menu on the toolbar, allowing users to: Export to various formats
3. Customize the report using Report Builder Create report subscriptions


To dislay reports in native mode you need to install the Report Viewer and the Report Explorer web part which resides at the following location C:\Program Files\Microsoft SQL Server\90 or 80 \Tools\Reporting Services\SharePoint

To install this web part using command line is as follows

stsadm -o addwppack -filename “(Folder of the cab file)\RSWebParts.cab” -globalinstall

Adding web part and configuring the webpart

1. Open a Web Part page in your SharePoint Web Application
Set your page in edit mode: Site Action -> Edit Page, and click ‘Add a Web Part’ in the zone where you would like to add the Web Part.

2. In the Add Web Parts dialog box, scroll down to Miscellaneous. Select Report Explorer or Report Viewer if you want to add both Web Parts, and then click Add.
Know modify the settings of the Report Web Part. In Report Manager URL, type your URL to a Report Manager instance. By default, a Report Manager URL has the following syntax: http:///reports. For this setting you can also set the Start Path.

3.The Web Parts also allows you to connect the Report Explore to the Report Viewer. This connection can be set in the edit mode of the page:

4. Click on the edit button of the title bar of the Report Explorer Web Part
Point to Connections and follow that up by pointing to ‘Show report in’, and then click ‘Report Viewer’

May 15, 2009

Sharepoint Interview Questions Part 2

hi guys here goes the second section

1. what is SharePoint?
Portal Collaboration Software.

2. what is the difference between SharePoint Portal Server and Windows SharePoint Services?
SharePoint Portal Server is the global portal offering features like global navigation and searching. Windows SharePoint Services is more content management based with document libraries and lists. You apply information to certain areas within your portal from Windows SharePoint Services or directly to portal areas.

3. what is a document library?
A document library is where you upload your core documents. They consist of a row and column view with links to the documents. When the document is updated so is the link on your site. You can also track metadata on your documents. Metadata would consist of document properties.

4. what is a meeting workspace?
A meeting workspace is a place to store information, attendees, and tasks related to a specific meeting.

5. what is a document workspace?
Document workspaces consist of information surrounding a single or multiple documents.

6. what is a web part?
Web parts consist of xml queries to full SharePoint lists or document libraries. You can also develop your own web parts and web part pages.

7. what is the difference between a document library and a form library?
Document libraries consist of your core documents. An example would be a word document, excel, powerpoint, visio, pdf, etc… Form libraries consist of XML forms.

8. what is a web part zone?
Web part zones are what your web parts reside in and help categorize your web parts when designing a page.

9. how is security managed in SharePoint?
Security can be handled at the machine, domain, or sharepoint level.

10. how are web parts developed?
Web parts are developed in Visual Studio .Net. VS.Net offers many web part and page templates and can also be downloaded from the Microsoft site.

11. what is a site definition?
It’s a methods for providing prepackaged site and list content.

12. what is a template?
A template is a pre-defined set of functions or settings that can be used over time. There are many templates within SharePoint, Site Templates, Document Templates, Document Library and List Templates.

13. how do you install web parts?
Web Parts should be distributed as a .CAB (cabinet) file using the MSI Installer.

14. what is CAML?
tands for Collaborative Application Markup Language and is an XML-based language that is used in Microsoft Windows SharePoint Services to define sites and lists, including, for example, fields, views, or forms, but CAML is also used to define tables in the Windows SharePoint Services database during site provisioning.

15. what is a DWP?
he file extension of a web part.

16. what is the GAC?
Global Assembly Cache folder on the server hosting SharePoint. You place your assemblies there for web parts and services.

17. what are the differences between web part page gallery, site gallery, virtual server gallery and online gallery?
Web Part Page Gallery is the default gallery that comes installed with SharePoint. Site Gallery is specific to one site. Virtual Server gallery is specific to that virtual server and online gallery are downloadable web parts from Microsoft.

18. what is the difference between a site and a web?
The pages in a Web site generally cover one or more topics and are interconnected through hyperlinks. Most Web sites have a home page as their starting point. While a Web is simply a blank site with SharePoint functionality built in; meaning you have to create the site from the ground up.

19. What is Microsoft Windows SharePoint Services? How is it related to Microsoft Office SharePoint Server 2007?
Windows SharePoint Services is the solution that enables you to create Web sites for information sharing and document collaboration. Windows SharePoint Services — a key piece of the information worker infrastructure delivered in Microsoft Windows Server 2003 — provides additional functionality to the Microsoft Office system and other desktop applications, and it serves as a platform for application development.
Office SharePoint Server 2007 builds on top of Windows SharePoint Services 3.0 to provide additional capabilities including collaboration, portal, search, enterprise content management, business process and forms, and business intelligence.

20. What is Microsoft SharePoint Portal Server?
SharePoint Portal Server is a portal server that connects people, teams, and knowledge across business processes. SharePoint Portal Server integrates information from various systems into one secure solution through single sign-on and enterprise application integration capabilities. It provides flexible deployment and management tools, and facilitates end-to-end collaboration through data aggregation, organization, and searching. SharePoint Portal Server also enables users to quickly find relevant information through customization and personalization of portal content and layout as well as through audience targeting.

21. What is Microsoft Windows Services?
Microsoft Windows Services is the engine that allows administrators to create Web sites for information sharing and document collaboration. Windows SharePoint Services provides additional functionality to the Microsoft Office System and other desktop applications, as well as serving as a plat form for application development. SharePoint sites provide communities for team collaboration, enabling users to work together on documents, tasks, and projects. The environment for easy and flexible deployment, administration, and application development.

22. What is the relationship between Microsoft SharePoint Portal Server and Microsoft Windows Services?
Microsoft SharePoint Products and Technologies (including SharePoint Portal Server and Windows SharePoint Services) deliver highly scalable collaboration solutions with flexible deployment and management tools. Windows SharePoint Services provides sites for team collaboration, while Share Point Portal Server connects these sites, people, and business processes—facilitating knowledge sharing and smart organizations. SharePoint Portal Server also extends the capabilities of Windows SharePoint Services by providing organizational and management tools for SharePoint sites, and by enabling teams to publish information to the entire organization.

23. Who is Office SharePoint Server 2007 designed for?
Office SharePoint Server 2007 can be used by information workers, IT administrators, and application developers.
is designed

24. What are the main benefits of Office SharePoint Server 2007?

Office SharePoint Server 2007 provides a single integrated platform to manage intranet, extranet, and Internet applications across the enterprise.
* Business users gain greater control over the storage, security, distribution, and management of their electronic content, with tools that are easy to use and tightly integrated into familiar, everyday applications.
* Organizations can accelerate shared business processes with customers and partners across organizational boundaries using InfoPath Forms Services–driven solutions.
* Information workers can find information and people efficiently and easily through the facilitated information-sharing functionality and simplified content publishing. In addition, access to back-end data is achieved easily through a browser, and views into this data can be personalized.
* Administrators have powerful tools at their fingertips that ease deployment, management, and system administration, so they can spend more time on strategic tasks.
* Developers have a rich platform to build a new class of applications, called Office Business Applications, that combine powerful developer functionality with the flexibility and ease of deployment of Office SharePoint Server 2007. Through the use of out-of-the-box application services, developers can build richer applications with less code.

25. What is the difference between Microsoft Office SharePoint Server 2007 for Internet sites and Microsoft Office SharePoint Server 2007?
Microsoft Office SharePoint Server 2007 for Internet sites and Microsoft Office SharePoint Server 2007 have identical feature functionality. While the feature functionality is similar, the usage rights are different.
If you are creating an Internet, or Extranet, facing website, it is recommended that you use Microsoft Office SharePoint Server 2007 for Internet sites which does not require the purchase client access licenses. Websites hosted using an “Internet sites” edition can only be used for Internet facing websites and all content, information, and applications must be accessible to non-employees. Websites hosted using an “Internet sites” edition cannot be accessed by employees creating, sharing, or collaborating on content which is solely for internal use only, such as an Intranet Portal scenario. See the previous section on licensing for more information on the usage scenarios.

26. What suites of the 2007 Microsoft Office system work with Office SharePoint Server 2007?
Office Outlook 2007 provides bidirectional offline synchronization with SharePoint document libraries, discussion groups, contacts, calendars, and tasks.
Microsoft Office Groove 2007, included as part of Microsoft Office Enterprise 2007, will enable bidirectional offline synchronization with SharePoint document libraries.
Features such as the document panel and the ability to publish to Excel Services will only be enabled when using Microsoft Office Professional Plus 2007or Office Enterprise 2007.
Excel Services will only work with documents saved in the new Office Excel 2007 file format (XLSX).

27. How do I invite users to join a Windows SharePoint Services Site? Is the site secure?
SharePoint-based Web sites can be password-protected to restrict access to registered users, who are invited to join via e-mail. In addition, the site administrator can restrict certain members' roles by assigning different permission levels to view post and edit.

28. Can I post any kind of document?
You can post documents in many formats, including .pdf, .htm and .doc. In addition, if you are using Microsoft Office XP, you can save documents directly to your Windows SharePoint Services site.

29. Can I download information directly from a SharePoint site to a personal digital assistant (PDA)?
No you cannot. However, you can exchange contact information lists with Microsoft Outlook.

30. How long does it take to set up the initial team Web site?
It only takes a few minutes to create a complete Web site. Preformatted forms let you and your team members contribute to the site by filling out lists. Standard forms include announcements, events, contacts, tasks, surveys, discussions and links.
31. Can I create custom templates?
Yes you can. You can have templates for business plans, doctor's office, lawyer's office etc.

32. How can I make my site public? By default, all sites are created private.
If you want your site to be a public Web site, enable anonymous access for the entire site. Then you can give out your URL to anybody in your business card, e-mail or any other marketing material. The URL for your Web site will be:
http:// yoursitename.wss.bcentral.com
Hence, please take special care to name your site.
These Web sites are ideal for information and knowledge intensive sites and/or sites where you need to have shared Web workspace.
Remember: Under each parent Web site, you can create up to 10 sub-sites each with unique permissions, settings and security rights.

33. How do the sub sites work?
You can create a sub site for various categories. For example:
* Departments - finance, marketing, IT
* Products - electrical, mechanical, hydraulics
* Projects - Trey Research, Department of Transportation, FDA
* Team - Retention team, BPR team
* Clients - new clients, old clients
* Suppliers - Supplier 1, Supplier 2, Supplier 3
* Customers - Customer A, Customer B, Customer C
* Real estate - property A, property B
The URLs for each will be, for example:
* http://yoursitename.wss.bcentral.com/finance
* http://yoursitename.wss.bcentral.com/marketing
You can keep track of permissions for each team separately so that access is restricted while maintaining global access to the parent site.

34. How do I make my site non-restricted?
If you want your site to have anonymous access enabled (i.e., you want to treat it like any site on the Internet that does not ask you to provide a user name and password to see the content of the site), follow these simple steps:
# Login as an administrator
# Click on site settings
# Click on Go to Site Administration
# Click on Manage anonymous access
# Choose one of the three conditions on what Anonymous users can access:
** Entire Web site
** Lists and libraries
** Nothing
Default condition is nothing; your site has restricted access. The default conditions allow you to create a secure site for your Web site.

35. Can I get domain name for my Web site?
Unfortunately, no. At this point, we don't offer domain names for SharePoint sites. But very soon we will be making this available for all our SharePoint site customers. Please keep checking this page for further update on this. Meanwhile, we suggest you go ahead and set up your site and create content for it.

36. What are picture libraries?
Picture libraries allow you to access a photo album and view it as a slide show or thumbnails or a film strip. You can have separate folder for each event, category, etc

37. What are the advantages of a hosted SharePoint vs. one that is on an in-house server?
* No hardware investment, i.e. lower costs
* No software to download - ready to start from the word go
* No IT resources - Anyone who has used a Web program like Hotmail can use it
* Faster deployment

38. Can I ask users outside of my organization to participate in my Windows SharePoint Services site?
Yes. You can manage this process using the Administration Site Settings. Simply add users via their e-mail alias and assign permissions such as Reader or Contributor.

39. Are there any IT requirements or downloads required to set up my SharePoint site?
No. You do not need to download any code or plan for any IT support. Simply complete the on-line signup process and provide us your current and correct email address. Once you have successfully signed up and your site has been provisioned, we will send a confirmation to the email address you provided.

40. I am located outside of the United States. Are there any restrictions or requirements for accessing the Windows SharePoint Services?
No. There are no system or bandwidth limitations for international trial users. Additionally language packs have been installed which allow users to set up sub-webs in languages other than English. These include: Arabic, Danish, Dutch, Finnish, French, German, Hebrew, Italian, Japanese, Polish, Portuguese (Brazilian), Spanish and Swedish.

Sharepoint Interview Questions Part 1

Hi Guys, here are few sharepoint interview question which i gathered from various blogs and sites. Will try to keep this section updated with new questions as much as possible. Here is the first part of the section.

1) What are the two base classes a WebPart you are going to use within SharePoint 2007 can inherit from?
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

2) What are the differences between the two base classes and what are the inherit benefits of using one over another?
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.

3) What is the GAC?
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.

4) What is strong naming (signing) a WebPart assembly file mean?
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.

5) What are safe controls, and what type of information, is placed in that element in a SharePoint web.config file?
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.

6) What is the CreateChildControls() method? How can you use it to do something simple like displaying a Label control?
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.

7) 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.
*** Side Question: I got asked what the difference between CreateChildControls and the RenderContents method. 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.

8) 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. It is known as the “the central class of the Web Part Control Set.”
*** Side Question: I got asked how many WebPartManager controls should be on a page. In order to have WebParts on a page there has to be just one WebPartManager control to manage all the WebParts on the page.

9) 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.

10) How would you go about getting a reference to a site?
Select For Unformatted Code
C#:

oSPSite = new SPSite("http:/server");
oSPWeb = oSPSite.OpenWeb();


11) 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.

12) 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.
Side Question: I got asked if there are other ways to send emails from SharePoint. The answer is 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.

13) How do you connect (reference) to a SharePoint list, and how do you insert a new List Item?
Select For Unformatted Code

C#:

using(SPSite mySite = new SPSite("yourserver"))
{
using(SPWeb myWeb = mySite.OpenWeb())
{
SPList interviewList = myWeb.Lists["listtoinsert"];
SPListItem newItem = interviewList.Items.Add();
newItem["interview"] = "interview";
newItem.Update();
}
}



14) 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?
Select For Unformatted Code
C#:


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


15) 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.
Side Question: I got asked how I built queries with the lists.asmx web service. In order to build queries with this service, one of the parameters that the GetListItems method exposes is the option to build a CAML query. There are other ways to do this as well, but that was how I answered it.

16) 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.
*** Side Question: I got asked when you should state the credentials in code. 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.

17) 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.

18) What is impersonation, and when would you use impersonation?
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.

19) What is the IDesignTimeHtmlProvider interface, and when can you use it in WebParts?
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.

20) What are WebPart properties, and what are some of the attributes you see when declaring WebPart properties in code?
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.

21) Why are properties important in WebPart development, and how have you exploited them in past development projects? What must each custom property have?
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.

22) What are ClassResources? How do you reference and deploy resources with an ASP.NET 2.0 WebPart?
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.

23) What is a SharePoint Solution File? How does it differ from WebPart .cab files in legacy development? What does it contain?
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
Just to name a few things…

24) What is a .ddf file and what does it have to do with SharePoint Solution creation?
A .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.

25) What file does a SharePoint solution package use to orchestrate (describe) its packaged contents?
The solution Manifest.XML file.

26) What deployment mechanism can you use to instigate Code Access Security attributes for your WebParts?
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.

27) 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. Features have their own receiver architecture, which allow you to trap events such as when a feature is installing, uninstalling, activated, or deactivated. They are helpful because they allow ease of upgrades and versioning.
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.
Side Question: I got asked how the introduction of features has changed the concept of site definitions. 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.

28) What types of SharePoint assets can be deployed with a SharePoint feature?
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
just to name a few….

29) 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.

30) When would you use an event receiver?
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.

31) 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.

32) 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.

33) 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 sister synchronous event is ItemAdding.

34) How could you append a string to the title of a site when it is provisioned?
In the OnActivated event:
Select For Unformatted Code
C#:
1. SPWeb site = siteCollection.RootWeb;
2. site.Title += "interview";
3. site.Update();

35) Can an event receiver be deployed through a SharePoint feature?
Yes.

36) What is a content type?
A content type is an information blueprint basically that can be re-used throughout a SharePoint environment for defining things like metadata and associated behaviors. It is basically an extension of a SharePoint list, however makes it portable for use throughout an instance regardless of where the instantiation occurs, ergo has location independence. Multiple content types can exist in one document library assuming that the appropriate document library settings are enabled. The content type will contain things like the metadata, listform pages, workflows, templates (if a document content type), and associated custom written functionality.

37) Can a content type have receivers associated with it?
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.

38) What two files are typically (this is kept generally) included when developing a content type, and what is the purpose of each?
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.

39) 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.

40) 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.

41) 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.

42) 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.

43) What base class do 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.

44) What is a SharePoint site definition? What is ghosted (uncustomized) and unghosted (customized)?
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. Ghosted means that when SharePoint creates a new site it will reference the files in the related site definition upon site provisioning. Unghosted means that the site has been edited with an external editor, and therefore the customizations are instead stored in the database, breaking the inheritance of those files from the file system.

45) 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.

May 12, 2009

SPUser Detail from Person-Group Field from SharePoint List

SPUser Detail from Person-Group Field from SharePoint List
Recently while working on custom timer job I ran into a scenario where I need SPUser detail for sending mail from the Person/Group Field value in the SharePoint list. Initially while doing this it would be very simple just by typecasting it, but it doesn’t seem to work.

After reading few article I came to conclusion that to create a SPUser from the value present in the Person/Group field, first we need to create a SPFieldUser object and get the required Field instance and assign to this object, next create a SPFieldUser Value object and assign the value using the GetFieldValue method of the SPFieldUser object. Finally Create a SPUser object and assign user value from the SPFieldUserValue.User.

The complete code snippet for the above logic is given below


SPFieldUser userField = (SPFieldUser)site.Lists["Gifts"].Fields.GetField("AccountOwner");
SPFieldUserValue fieldValue = (SPFieldUserValue)userField.GetFieldValue(item["AccountOwner"].ToString());
SPUser user = fieldValue.User;

string emailId = user.Email;

Failed to create feature receiver object from assembly

Today when i was working with Timer Job which i was creating with the help of item template I came across a very simple error when i was installing timer job as a feature.

The error details is as shown below:

Failed to create feature receiver object from assembly "Org.Project.Solution, Version=1.0.0.0, Culture=neutral, PublicKeyToken=12gav43334vw3445", type "Org.Project.Solution.MyFeature.FeatureReceiver" for feature 6a9b2358-ea4e-486d-a4e4-4f813c52ce88: System.ArgumentNullException: Value cannot be null.
Parameter name: type
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject()

It took me some time to figure it out the exact error, so thought of writing a post so that it would help you to fix the issue soon. In my feature.xml file for the timer job feature the Receiver Class was specified wrong, so next time guys when you get this error please verify your Receiver Assembly (it will be having the assembly name) And Receiver Class (it will be having feature installer class) correctly.

May 7, 2009

Template MetaData Files .VSTemplate extensions

To start with VSTemplate, lets first know where are VSTemplate files used.These files are used to create custom ItemTemplate and custom ProjectTemplate.Once these templates are created you can make it appear in the New New Item and the New Project dialog boxes.

1. ItemTemplates: All the templates that appear in the Add New Item Dialog Box are called Item Templates

2. ProjectTemplates: All the templates that appear in the Create/Add New Project Dialog Boxare called Project Templates

Before getting into creation of custom ItemTemplates, lets understand the structure of .VSTemplate which is the core part of Item and Project Templates

The .vstemplate file for project templates consists of three fundamental elements:

1. VSTemplate:  Identifies the template as a project or item template and provides the template version number. The attribute Type for VSTemplate specifies weather its project template or a Item Template

2. TemplateData: Categorizes the project template and defines   display characteristics for the New Project or Add New Item dialog box.It defines the name of the   tempalte,the description of what the template does, its default name and many other attritbute which we will  look into when we create a custom item template in the comnig posts





3. TemplateContent:Specifies the files included in the template.This part of the templates specifes what are the assembly references to be included, what are the default files need to be created when a new item is created usings this template





Apart from the above three fundamental there are other 2 optional sections, which may be needed during creation of custom templates

4. WizardExtension:This custom wizard helps to define additional custom functionality to the custom item templates, like adding the receiver class and the Recevice assembly into the feature dynamically


5. WizardData: This section of the VSTempalte helps us to pass custom xml to the custom wizard extension





Sample VSTemplate structure is shown below


<VSTemplate Version="2.0.0" Type="Item" 
xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
<TemplateData>
<Name>Timer Job</Name>
<Description>Add a new timer job</Description>
<ProjectType>CSharp</ProjectType>
<TemplateID>TimerJob</TemplateID>
<ShowByDefault>true</ShowByDefault>
<DefaultName>TimerJob</DefaultName>
<Icon>Icon.ico</Icon>
</TemplateData>
<TemplateContent>
<References>
<Reference>
<Assembly>
System.Web, Version=2.0.0.0, Culture=neutral,
 PublicKeyToken=b03f5f7f11d50a3a
       </Assembly>
</Reference>
<Reference>
<Assembly>Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral,
 PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL</Assembly>
</Reference>
</References>
<Folder Name="FolderName">
<ProjectItem SubType="Code" 
TargetFileName="feature.xml"
 ReplaceParameters="true">..\feature.xml</ProjectItem>
             <ProjectItem SubType="Code" 
TargetFileName="$rootname$.cs"
 ReplaceParameters="true">..\Job.cs</ProjectItem>
<ProjectItem SubType="Code" 
TargetFileName="$rootname$Installer.cs"
 ReplaceParameters="true">..\JobInstaller.cs</ProjectItem>
</Folder>
</TemplateContent>
<WizardExtension>
<Assembly>Wiz.CustomWizard, Version=1.0.0.0, Culture=neutral, 
PublicKeyToken=d24561bc194c5ab4, Custom=null</Assembly>
<FullClassName>Wiz.CustomWizard.CustWizard</FullClassName>
</WizardExtension>
</VSTemplate>

May 5, 2009

Custom template parameter name for Item Templates

Recently i thought of creating a ItemTemplates so that the dev effort during the development reduces drastically if someone is new to the project or the technology. A new developer just need to create a new item using the custom item templates.

Before getting into the deep on how to create custom item templates for visual studio. Please go through the list of reserverd template parameter names, whic will help developer to understand the naming conventions used for item templates.

All the template parameters are case sensitive
Reserved Template Parameters
The following table lists the reserved template parameters that can be used by any template.

1. clrversion
Current version of the common language runtime (CLR).
2. GUID [1-10]
A GUID used to replace the project GUID in a project file.
You can specify up to 10 unique GUIDs (for example, guid1).
3. itemname
The name provided by the user in the Add New Item dialog box.
4. machinename
The current computer name (for example, Computer01).
5. projectname
The name provided by the user in the New Project dialog box.
6. registeredorganization
The registry key value from HKLM\Software\Microsoft
\Windows NT\CurrentVersion\RegisteredOrganization.
7. rootnamespace
The root namespace of the current project. This parameter is
used to replace the namespace in an item being added to a project.
8. safeitemname
The name provided by the user in the Add New Item dialog box,
with all unsafe characters and spaces removed.
9. safeprojectname
The name provided by the user in the New Project dialog box,
with all unsafe characters and spaces removed.
10. time
The current time in the format DD/MM/YYYY 00:00:00.
11. userdomain
The current user domain.
12. username
The current user name.
13. year
The current year in the format YYYY.