Sunday 27 May 2012

Abbreviations in .NET

ADO – ActiveX Data Object – Microsoft ActiveX Data Objects (ADO) is a collection of Component Object Model objects for accessing different types of data sources.
AJAX – Asynchronouse Javascript and XML – Ajax is a web development technology used for creating interactive web pages with fast data rendering by enabling partial postbacks on a web page (That means a section of the web page is rendered again, instead of the complete web page. This is achieved using Javascript, XML, JSON (Javascript Notation Language) and the XMLHttpRequest object in javascript.

ASP – Active Server Pages – Microsoft’s Server side script engine for creating dynamic web page.
C# – C Sharp – Microsoft Visual C# is an object oriented programming language based on the .NET Framework. It includes features of powerful languages like C++, Java, Delphi and Visual Basic.
CAO – Client Activated Object – Objects created on the server upon the client’s request. This is used in Remoting.
CCW – COM Callable Wrapper – This component is used when a .NET component needs to be used in COM.
CIL – Common Intermediate Language – Its actually a low level human readable language implementation of CLI. All .NET-aware languages compile the source oode to an intermediate language called Common Intermediate Language using the language specific compiler.
CLI – Common Language Infrastructure – This is a subset of CLR and base class libraries that Microsoft has submitted to ECMA so that a third-party vendor can build a .NET runtime on another platform.
CLR – Common Language Runtime – It is the main runtime machine of the Microsoft .NET Framework. It includes the implementation of CLI. The CLR runs code in the form of bytes, called as bytecode and this is termed MSIL in .NET.
CLS – Common Language Specification – A type that is CLS compliant, may be used across any .NET language. CLS is a set of language rules that defines language standards for a .NET language and types declared in it. While declaring a new type, if we make use of the [CLSCompliant] attribute, the type is forced to conform to the rules of CLS.
COFF – Common Object File Format – It is a specification format for executables.
COM – Component Object Model – reusable software components. The tribe of COM components includes COM+, Distributed COM (DCOM) and ActiveX® Controls.
CSC.exe – C Sharp Compiler utility
CTS – Common Type System – It is at the core of .NET Framework’s cross-language integration, type safety, and high-performance code execution. It defines a common set of types that can be used with many different language syntaxes. Each language (C#, VB.NET, Managed C++, and so on) is free to define any syntax it wishes, but if that language is built on the CLR, it will use at least some of the types defined by the CTS.
DBMS – Database Management System – a software application used for management of databases.
DISCO – Discovery of Web Services. A Web Service has one or more. DISCO files that contain information on how to access its WSDL.
DLL – Dynamic Link Library – a shared reusable library, that exposes an interface of usable methods within it.
DOM – Document Object Model – is a language independent technology that permits scripts to dynamically updated contents of a document (a web page is also a document).
ECMA – European Computer Manufacturer’s Association – Is an internation organisation for computer standards.
GC – Garbage Collector – an automatic memory management system through which objects that are not referenced are cleared up from the memory.
GDI – Graphical Device Interface – is a component in Windows based systems, that performs the activity of representing graphical objects and outputting them to output devices.
GAC – Global Assembly Cache – Is a central repository of reusable libraries in the .NET environment.
GUI – Graphic User Interface – a type of computer interface through which user’s may interact with the Computer using different types of input & output devices with a graphical interface.
GUID – Globally Unique Identifier – is a unique reference number used in applications to refer an object.
HTTP – Hyper Text Transfer Protocol – is a communication protocol used to transfer information in the internet. HTTP is a request-response protocol between servers and clients.
IDE – Integrated Development Environment – is a development environment with source code editor with a compiler(or interpretor), debugging tools, designer, solution explorer, property window, object explorer etc.
IDL – Interface Definition Language – is a language for defining software components interface.
ILDASM – Intermediate Language Disassembler – The contents of an assembly may be viewed using the ILDASM utility, that comes with the .NET SDK or the Visual Studio.NET. The ildasm.exe tool may also be used in the command line compiler.
IIS – Internet Information Server – Is a server that provides services to websites and even hosts websites.
IL – Intermediate Language – is the compiled form of the .NET language source code. When .NET source code is compiled by the language specific compiler (say we compile C# code using csc.exe), it is compiled to a .NET binary, which is platform independent, and is called Intermediate Language code. The .NET binary also comprises of metadata.
JIT – Just in Time (Jitter) – is a technology for boosting the runtime performance of a system. It converts during runtime, code from one format into another, just like IL into native machine code. Note that JIT compilation is processor specific. Say a processor is X86 based, then the JIT compilation will be for this type of processor.
MBR – MarshallByReference – The caller recieves a proxy to the remote object.
MBV – MarshallByValue – The caller recieves a copy of the object in its own application domain.
MDI – Multiple Document Interface – A window that resides under a single parent window.
MSIL – Microsoft Intermediate Language – now called CIL.
Orcas – Codename for Visual Studio 2008
PE – Portable Executable – an exe format file that is portable.
RAD – Rapid Application Development
RCW – Runtime Callable Wrapper – This component is used when a .NET needs to use a COM component.
SAX – Simple API for XML – It is a serial access parser API for XML. The parser is event driven and the event gets triggered when an XML feature is encountered.
SDK – Software Development Kit
SMTP – Simple Mail Transfer Protocol – a text based protocol for sending mails.
SN.exe – Strong Name Utility – a tool to make strong named assemblies.
SQL – Structured Query Language – a language for management of data in a relational structure.
SOAP – Simple Object Access Protocol – a protocol used for exchange of xml based messages across networks.
TCP – Transmission Control Protocol – data exchange protocol across networks using streamed sockets.
UI – User Interface
URI – Uniform Resource Identifier
URL – Uniform Resource Locator
UDDI – Universal Description, Discovery and Integration – it is a platform independent business registration across the internet.
WAP – Wireless Access Protocol – a protocol that enables access to the internet from mobile phones and PDAs.
WC – Windows Cardspace – Part of .NET 3.0 framework, that enables users to secure and store digital identities of a person, and a provision to a unified interface for choosing the identity for a particular transaction, like logging in to a website.
WCF – Windows Communication Foundation – Part of .NET 3.0 framework, that enables communication between applications across machines.
WF – Windows Workflow Foundation – Part of .NET 3.0 framework, used for defining, execution and management of reusable workflows.
WKO – Well Known Object – These are MBR types whose lifetime is controlled by the server’s application domain.
WPF – Windows Presentation Foundation – Part of .NET 3.0 framework, is the graphical subsystem of the .NET 3.0 framework.
WSDL – Web Services Description Language – is an XML based language for describing web services.
WML – Wireless Markup Language – is a content format for those devices that use Wireless Application Protocol.
VB.NET – Visual Basic .NET – .NET based language. Its the .NET implementation of VB6, the most widely used language in the world.
VBC.exe – VB.NET Compiler
VES – Virtual Execution System – It provides the environment for execution of managed code. It provides direct support for a set of built in data types, defines a hypothetical machine with an associated machine model and state, a set of control flow constructs, and an exception handling model. To a large extent, the purpose of the VES is to provide the support required to execute the Common Intermediate Language instruction set.
VS – Visual Studio
VSS – Visual Source Safe – An IDE by Microsoft, to maintain source code versions and security.
VSTS – Visual Studio Team Suite – Visual Studio Team System – it is an extended version of Visual Studio .NET. It has a set of collaboration and development tools for software development process.
XML – Extensible Markup Language – is a general purpose well formed markup language.

Windows SharePoint Services Object Model

 
Identity : Microsoft.SharePoint
Description : Windows SharePoint Services
Path : To add a reference to a Sharepoint API, Right-click the project(in VS) and select Add   Reference. Click the Browse tab and select the following directory:
       C:\program files\common files\microsoft shared\web server extensions\12\isapi

Some useful Microsoft.SharePoint Namespaces follows with Description :

Microsoft.SharePoint
Provides types and members for working with a top-level site and its subsites or lists.

Microsoft.SharePoint.Administration
Provides administrative types and members for managing a Windows SharePoint Services deployment.

Microsoft.SharePoint.Administration.Backup
Provides types and members for performing backup and restore operations on SharePoint sites.

Microsoft.SharePoint.Deployment
Provides types and members for importing and exporting content between Windows SharePoint Services Web sites.

Microsoft.SharePoint.Dsp
Provides the base class for the data retrieval service adapters used in Windows SharePoint Services.

Microsoft.SharePoint.Meetings
Provides types and members that can be used to customize Meeting Workspace sites.

Microsoft.SharePoint.MobileControls
Provides server controls for rendering the mobile forms and view pages used in SharePoint lists.

Microsoft.SharePoint.Navigation
Provides types and members for customizing the navigation structures and site maps of SharePoint Web sites.

Microsoft.SharePoint.Search
    Microsoft.SharePoint.Search.Internal.Protocols
    Microsoft.SharePoint.Search.Internal.Protocols.SiteData
    Microsoft.SharePoint.Search.Internal.Protocols.SPSCrawl
    Microsoft.SharePoint.Search.Internal.UI
    Microsoft.SharePoint.Search.Internal.WebControls

Microsoft.SharePoint.Security
Provides a set of code access permission and attribute classes designed to protect a specific set of resources and operations, such as access to the Windows SharePoint Services object model, the ability to do unsafe saving on HTTP Gets, and enabling point-to-point Web Part connections.

Microsoft.SharePoint.StsAdmin
Provides an interface for creating custom operations to run at the command prompt in STSADM.EXE

Microsoft.SharePoint.Upgrade

Provides types and members for upgrading a Windows SharePoint Services deployment.

Microsoft.SharePoint.Utilities
Provides utilities for encoding strings and processing user information.

Microsoft.SharePoint.WebControls
Provides server controls that are used on site and list pages in a SharePoint site.

Microsoft.SharePoint.WebPartPages
Provides classes, interfaces, and members for creating custom Web Parts and Web Part pages

Microsoft.SharePoint.Workflow
Provides types and members for associating, initiating, and managing workflow templates and instances.

Microsoft.SharePoint.WorkflowActions
Provides types that represent workflow activities. These activities can be assembled into workflow activities.
 

Some useful Microsoft.SharePoint Classes follows with Description and Example :

SPSite
    Represents a collection of sites in a Web application, including a top-level Web site and all its subsites. Each SPSite object, or site collection, is represented within an SPSiteCollection object that consists of the collection of all site collections in the Web application.
    E.g : SPSite siteCollection = SPControl.GetContextSite(Context);

SPWeb
    Represents a Windows SharePoint Services Web site.
    E.g : SPWeb objWebSite = siteCollection.OpenWeb();   

SPWebCollection
    Represents a collection of SPWeb objects.
    E.g : SPWebCollection objWebCollection = siteCollection.AllWebs;
SPSecurity
    Provides static security management properties and methods.
    E.g : SPSecurity.CodeToRunElevated myCode =
            new SPSecurity.CodeToRunElevated(ShowFeatures);
          SPSecurity.RunWithElevatedPrivileges(myCode);
SPListCollection
    Represents a collection of SPList objects.
    E.g : SPListCollection objListCollection = objWebSite.Lists ;
SPList
    Represents a list on a SharePoint Web site.
    E.g : foreach(SPLists objLists in objListCollection)
SPUser
    Represents a user in Microsoft Windows SharePoint Services.
    E.g : SPUser objUser = objWebSite.CurrentUser ;
 ****************************************************************
SharePoint 2010 Object Model

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

Notes:
* To use the SharePoint API, your code must reside on one of the machines in a SharePoint
application server farm. Your code can still work with other sites in the farm from any
other site in the farm, but you cannot, for example, work with the SharePoint API from a
machine on which MOSS or WSS is not installed.

* The only practical way to consume SharePoint data and functionality from a remote client is to use the SharePoint web services.

* The object model is not designed to support Remoting



Sharepoint Webparts Workflows custom controls Questions

Q) How can we use custom controls in SharePoint?

Step 1:- Create the custom control by inheriting from the ‘WebControl’ class and override the ‘RenderContents’ method with your implementation. In the below code snippet we are just writing the site title and site URL to the browser.
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.SharePoint;
namespace NameSpaceCustomControl
{
          public class CustomControl1 : WebControl
          {
                    protected override void RenderContents(HtmlTextWriter output)
                   {
                   SPWeb  rootSite = SPContext.Current.Web;
                   output.Write("The Site title is " + rootSite.Title);
                   output.Write("<br/>");
                   output.Write("The URL of the site is " + rootSite.Url);
                   }
          }
}
Step 2 : Compile the custom control class and generate the DLL from the same. Once the compiled DLL is generated, register the same in GAC.
Step 3: Refer the custom control assembly in your ASPX page using the register
attribute. Please note to specify the public key token of the GAC.
<%@ Register Assembly="CustomControl,Version=1.0.0.0,Culture=neutral,PublicKeyToken=4adae03f3c0d5b8e"
Namespace="NameSpaceCustomControl" TagPrefix="CustomSitePages" %>
Specify the custom control with a proper unique ID.
<CustomSitePages:CustomControl1 ID="cc1" runat="server" />
Below is the complete code of the page.
<%@ Page Language="C#" MasterPageFile="~masterurl/default.master" meta:progid="SharePoint.WebPartPage.Document"%>
<%@ Register Assembly="CustomControl,Version=1.0.0.0,Culture=neutral,PublicKeyToken=4adae03f3c0d5b8e"
Namespace="NameSpaceCustomControl" TagPrefix="CustomSitePages" %>
<asp:Content runat="server" ContentPlaceHolderID="PlaceHolderMain">
<h2>Hi this is a JaganInfo Site Page</h2>
<CustomSitePages:CustomControl1 ID="cc1" runat="server" />
</asp:Content>
-----------------
Q ) What are WebParts and how does it interact with SharePoint ?
It helps to build reusable components which can customized and personalized according to business user. We can either make our own webpart or we can reuse the existing one's from SharePoint itself.
Web Parts are the fundamental building blocks for Share Point user interface, and with them we can build and integrate many different types of applications.In share point also be create custom web part using .oscx control
Steps create custom web part
   1. create web part project copied .oscx control and build application.place .dll file in GAC .reset IIS.
   2. go 12 hive _layout folder create folder past your .oscx control
   3. go inetpub ->wwwroot->wss->open Your site ->web con fig->create safe control write assembly information of web part application
   4. open sharepoint site ->site action-site editing->Galleries ->web part->new Add your web part.
Following few WebParts are available in WSS 3.0
Data View Web Part : Displays data with rich design support through Microsoft SharePoint Designer.
List View Web Part : Helps us to display list content for any list in the SharePoint site.
 
Image Web Part : Helps us to display image files.
Content Editor Web Part : Use this to display static HTML content using a WYSIWYG editor or to link to a text file.
Members Web Part : Helps us to display members of the site.
Page Viewer Web Part: Displays web page in an Iframe.
WebPart is nothing but a simple class which inherits from System.Web.UI.WebControls.WebParts.
In other words you can say WebPart is kind of a WebControl which can be deployed in a WebPartZoneControl.
------------------
Q ) WebPart life cycle events
OnInit : This is the initialization event and is the first event to occur.
OnLoad :  The load event.
CreateChildControls :  When any child controls are added to a composite control this event fires.
EnsureChildControls :  This event makes sure that ‘CreateChildControls’ fires.
OnPreRender :  This fires just before the render event.Page.
PreRenderComplete :  When all controls have executed the ‘OnPreRender’ event this event fires.
Render :  Render the full control.
RenderContents :  Renders the contents of the control only.
Steps to create a WebPart in SharePoint
Step 1 : Create the Webpart
Step 2  :  Copy the compile DLL to the virtual directory in the BIN folder.
Step 3 :  Make entry of the WebPart in to web.config file.
Step 4 : Add it to the WebPart gallery
Step 5 : Add the WebPart to site pages.
Step 6 :  View the WebPart
---------------------------------------------------------
 Q) Workflows :
While workflow associations are often created directly on lists and document libraries, a workflow association can also be created on a content type that exists within the Content Type Gallery for the current site or content types defined within a list.
It can be applied
    * At the level of a list (or document library)
    * At the level of a content type defined at site scope
    * At the level of a site ( Sharepoint 2010 )
 What are the ways to initiate the workflow ?
    * Automatic (on item added or item deleted)
    * Manual (standard WSS UI interface)
    * Manual (Custom UI Interface)
    * Programatically through custom code
Types of input forms in Workflows
Can create four different types of input forms including
          an association form,
          an initiation form,
          a modification form, and
          a task edit form.
Note that these forms are optional when you create a workflow template.
Different types of Workflow
There are two basics type of workflow Sequential Workflow and State machines workflow.
 A sequential workflow has clear start and finish boundaries. Workflow controls execution in Sequential workflow. In sequential execution, one task is executed after other. Sequential workflow is more rigid in format and execution path has a determistic nature.
A State machine workflow is more dynamic in nature. Workflow has states and the state waits for events to help it move to next state. In State machine execution path is undetermestic nature.
Different stages of SharePoint workflow life cycle
There are four stage in the sharepoint workflow cycle associate, initiate, modify and complete.
Associate : As said workflows in sharepoint are always talked in context with a content type.
So the first step is to associate a workflow with a content type like list or a document.
Initiate : The second step is to initiate the workflow instance. Work flows are nothing but classes finally so a workflow instance needs to be created to start the work flow in action.
Modify : Later the workflow instance is modified as per the workflow stages.
Complete : Finally the workflow object is terminated.
How the workflow will be executed ?
• Administrator creates the initiates the task. The task is assigned to the reviewer.
• The reviewer then reviews the task, makes his comments and makes the task in progress. Once he makes the task in progress it’s automatically assigned to the acceptor.
• Acceptor finally does the complete review and closes the task.
 
---------------------------------------------------------
Q ) list types in SharePoint
Document library : Used for collaborating on documents with support for versioning, check-in and check-out, and workflow.
Form library : Used to store XML documents and forms for use with Microsoft Office InfoPath
Wiki page library : Used for collaborative Web pages based on wiki pages, which are dynamically generated and collaboratively edited Web pages.
Picture library : A specialized document library enhanced for use with pictures. Includes support for slide shows, thumbnails, and simple editing through Microsoft Office Picture Manager
Announcements : Used for simple sharing of timely news with support for expiration.
Contacts : A list for tracking people and contact information, with support for integration into Microsoft Office Outlook and other WSS-compatible contacts applications.
Discussions : A simple list for threaded discussions with support for approval and managing discussion threads.
Links : A list for managing hyperlinks.
Calendar : A list for tracking upcoming events and deadlines. Includes support for integration and synchronization with Office Outlook.
Tasks : A list of activity-based items that can integrate with workflow.
Project tasks : An enhanced tasks list with support for Gannt chart rendering and integration with Microsoft Office Project.
Issue tracking : A list for tracking issues and resolution, with support for prioritization.
Custom list : An empty list definition for extending with custom columns, or created using Microsoft Office Excel spreadsheets

sharepoint simple programs

Q) Write a program to fetch the Username
To fetch the User name in Console application is as follows


using Microsoft.SharePoint;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

            SPSite rootSite = new SPSite("http://jaganinfo-pc:1234/");
            SPWeb rootWeb=  rootSite.RootWeb;
            SPUserCollection  userList =  rootWeb.AllUsers;
            foreach (SPUser objUser in userList)
            {
                Console.WriteLine(objUser.Name);
            }
            Console.Read();
        }
    }
}
********************************************************************

Q) Write a Query SharePoint List by using LINQ


// Get DataContext from page context
DataContext data = new DataContext(SPContext.GetContext(this.Context).Web.Url);

// Get the SharePoint list
EntityList Customers = data.GetList("Customers");

// Query for customers from India
var indiaCustomers = from customer in Customers
where customer.City == "India"
select customer;

foreach (var indiaCust in indiaCustomers)
{
Console.Writeline("id = {0}, City = {1}", indiaCust.CustomerId, londonCust.City);
}
********************************************************************
Q) Write a program to Get All Alerts in the Site Collection
public void GetAlerts(Button btn)
    {
        SPSite rootSite = SPContext.Current.Site;
        SPWeb rootWeb = rootSite.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.

            SPList alertList = rootWeb.Lists[LIBName.Trim()];
            DeleteAllExistingItems(alertList, btn); // Delete existing items

            using (SPSite siteCollection = new SPSite(rootSite.ID))
            {
                foreach (SPWeb curretWeb in siteCollection.AllWebs)
                       //Get alerts for each web
                {
                    using (SPWeb web = siteCollection.OpenWeb(curretWeb.ID))
                    {
                        web.AllowUnsafeUpdates = true;

                        try
                        {
                            SPAlertCollection allAlerts = web.Alerts;

                            foreach (SPAlert AlertItem in allAlerts)
                            {
                                AddAlertToTable(alertList, AlertItem);
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Delete failed: " + ex.Message);
                            throw;
                        }

                        web.AllowUnsafeUpdates = false;
                    }
                }
            }

        });
    }
 ********************************************************************
Q) Programmatically Upload Documents in a Document Library
     public void DocumnetsUpload(SPWeb site)
    {
        if (FileUploadControl.HasFile)
        {
            SPFolder folder = site.GetFolder("Document_Library_Name");

            SPFileCollection files = folder.Files;

            //path of the file to upload
            Stream fStream = FileUpload1.PostedFile.InputStream;

            byte[] contents = new byte[fStream.Length];

            fstream.position = 0;

            fStream.Read(contents, 0, (int)fStream.Length);

            fStream.Close();

            string Filename = FileUpload1.FileName;

            string URL = SPContext.Current.Site.Url + "/Document_Library_Name/" + Filename;

            SPFile currentFile = files.Add(URL, contents);
        }
    }

 ******************************************************************** 
Q) Write a program to Delete all Items in a list
Note: Deleting all items in list will send all the items to recycle bin. To avoid fill-up recycle bin, we can just turn the recycle bin off while deleting the items.

public void DeleteAllItems(SPList CurrentList)
    {
        bool IsRecycleBinEnabled = SPContext.Current.Web.Site.WebApplication.RecycleBinEnabled;

        if (IsRecycleBinEnabled)
        {
            //set the use off the recyclebin to false SPContext.Current.Web.site.Webapplication.RecycleBinEnabled = fasle;
        }

        StringBuilder sbDelete = new StringBuilder();

        sbDelete.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?<Batch>");

        foreach (SPListItem item in CurrentList.Items)
        {
            sbDelete.Append("<Method>");

            sbDelete.Append("<SetList Scope=\"Request\"" + CurrentList.ID + "</SetList>");

            sbDelete.Append("<SetVar Name=\"ID\">" + Convert.ToString(item.ID) + "</SetVar>");

            sbDelete.Append("<SetVar Name=\"Cmd\"<Delete</SetVar>");

            sbDelete.Append("</Method>");
        }

        sbDelete.Append("</Batch>");
        try
        {
            SPContext.Current.Site.RootWeb.ProcessBatchData(sbDelete.ToString());
        }
        catch (Exception ex)
        {
            Console.WriteLine("Delete failed: " + ex.Message);
            throw;
        }
        if (!IsRecycleBinEnabled)
        {
            //set the use off the recyclebin to false
           //SPContext.Current.Web.site.Webapplication.RecycleBinEnabled = true;
        }
 ********************************************************************  
  Q)  SharePoint  search using FullTextSqlQuery
//Here SharedServices2 refers to the Shared Service Provider servicing the site in Question
    ServerContext context = ServerContext.GetContext("SharedServices2");
    FullTextSqlQuery qrySearch = new FullTextSqlQuery(context);
//Specifies the results set containing the main search results from
//the content index matching the search query.
    qrySearch.ResultTypes = ResultType.RelevantResults;
//Sremming : expansion of searches to include plural forms and
//other word variations :-)
    qrySearch.EnableStemming = true;
    qrySearch.TrimDuplicates = false;
    qrySearch.QueryText = "SELECT URL, Title, Size, Write, HitHighlightedSummary FROM SCOPE() where \"scope\"='NTFS Archive' And FREETEXT(*,'" + TextBox1.Text.Trim() +
"')";
    ResultTableCollection results = qrySearch.Execute();
    ResultTable resultTable = results[ResultType.RelevantResults];
// Data Table to Store Search Results
    DataTable dtResults = new DataTable();
    dtResults.Load(resultTable, LoadOption.OverwriteChanges);

Sharepoint template ID for event handlers

The following list template integer IDs that you can use in defining the template ID for event handlers.
List Template Id               List Template
100         Generic list
101         Document library
102         Survey
103         Links list
104         Announcements list
105         Contacts list
106         Events list
107         Tasks list
108         Discussion board
109         Picture library
110         Data sources
111         Site template gallery
113         Web Part gallery
114         List template gallery
115         XML Form library
120         Custom grid for a list
200         Meeting Series list
201         Meeting Agenda list
202         Meeting Attendees list
204         Meeting Decisions list
207         Meeting Objectives list
210         Meeting text box
211         Meeting Things To Bring list
212         Meeting Workspace Pages list
300         Portal Sites list
1100       Issue tracking
2002       Personal document library
2003       Private document library
  There are three main event classes:

    * SPItemEventReceiver
    * SPListEventReceiver
    * SPWebEventReceiver

Attributes of Feature.XML File

 
Attribute Value Description
ID GUID Contains the globally unique identifier (GUID) for the Feature.
Title Text Returns the title of the Feature. Limited to 255 characters.
Scope Farm/WebApplication/Site/Web Can contain one of the following values: Farm (farm), WebApplication (Web application), Site (site collection), and Web (Web site).
Hidden True/False This attribute equals FALSE by default.
AlwaysForceInstall True/False Optional Boolean. TRUE if the Feature is installed by force during installation even if the Feature is already installed. For example, if set to TRUE, Feature installation callouts will always fire anytime a user tries to install the Feature (even if it is already installed) by using either the scanforfeatures or installfeature command-line operation. This attribute equals FALSE by default. The AlwaysForceInstall attribute affects Features of all scopes.
 

SharePoint Interview Question and Answers

Q) Difference between MOSS and WSS
WSS is foundation and MOSS is optional add-on.
You cannot install MOSS of itself. If you try to do this, you will be requested to install WSS first.
Characteristics of WSS
It is a Web Based Application
It stores all information in an MS SQL database.
It displays information using web Parts.
It comes with site templates.
What WSS does not have?
There is no support for indexing and Searching.
It does not have advanced intranet features, such as targeted information and content management.
It has no record management.
It cannot display InfoPath forms in Web Browser.
It cannot display MS Excel spreadsheet as Web Part.
It comes with less than 10 Web parts.
It cannot Read and Write to External Database.
So to achieve all above task which WSS does not have, MOSS came into action.
MOSS 2007
Use global search functionality to find any type of information regardless of type and location.
Target information to one or more User Group.
Use Advanced Content Management.
Import User Data from Active Directory.
Use RSS web part to list information fetched from RSS feeds.
Give each SharePoint user a Personal Web Site.
Search, display content from external Database.
Comparison of Built in Feature of SharePoint
 Features       WSS    MOSS
Alerts            Yes     Yes
RSS              Yes     Yes
File and
 Document
 Management  Yes     Yes
Project 
Management   Yes     Yes
Managing
 Meeting        Yes     NO
Update          NO      Yes
Finding Information   NO      Yes
Indexing        NO      Yes
External Data access NO      Yes
SSP is nothing but collection of configured service to work with MOSS.
Q) What are Site Pages?   how are they different from application pages?
Site pages are customized pages and are saved in to content database. So when you use the SharePoint designer to make custom changes it saves the changes in to content database. If you want to make generic pages in a site collection which will be used by every one, like for instance the ‘Settings.aspx’ page then you need to use application pages.
In other words Site pages are nothing but customized pages stored in content, while application pages are generic pages which will be used by all the sites in a site collection
Q) What are site columns?
Site columns allows you to create a lookup columns in one location and share the column with any custom lists that would need it.
 Q) What is a Site Definition? How can you create a new Site Definition?
A site definition is a collection of files that defines the structure & layout of site templates. Confused? Well, don't be. A site definition comprised of a webtemp.xml file which  in turn defined the order of various site templates available in that site definition. Site definition file also include a separate directory structure that includes all the other core files required. The webtemp.xml file is stored in %COMMONPROGRAMFILES%\Microsoft Shared\web server extensions\14\TEMPLATE\1033\XML location and directory that contains all the core files is %COMMONPROGRAMFILES%\Microsoft Shared\web server extensions \14\TEMPLATE\SiteTemplates.
Steps for creating a custom Site Definition
Step 1.Create a copy of existing site Definition structure by navigating to %COMMONPROGRAMFILES%\\Microsoft Shared\web server extensions\14\TEMPLATE\SiteTemplates. Rename the file as NewLOB (short form for New line of business).
Step 2. Navigate to %COMMONPROGRAMFILES%\\Microsoft Shared\web server extensions\14\TEMPLATE\1033 and copy the STS directory and paste it in the same strucutre and rename it as NewLOB.
Step 3. Create webTemp.xml file to register the site definition created in step 1&2.
Step 4. Reset IIS.
Thats it. Now, new site definition is available for use for the new line of business group.
Q) Explain the concept of ghosting/unghosting?
First of all, with the release of WSS 3.0, Microsoft has renamed the concept of ghosting/unghosting as uncustomized/customized pages .
In SharePoint most of the site pages derive from templates. The custom pages only store the difference between them. The template is loaded in memory and applied to the custom pages on fly. In other words the template is stored in a cache. This definitely brings in performance and flexibility. Flexibility is in terms that when we change the template page it’s applied to all custom pages. These pages are loaded from the file system. So pages which are loaded from the file system are termed as ghosted pages.
If the page data is loaded from the content database it’s termed as unghosted pages.
Q) Content types in SharePoint
A content type is a flexible and reusable WSS type definition that defines the columns and behavior for an item in a list or a document in a document library.
E.g : you can create a content type for a customer presentation document with a unique set of columns, an event handler, and its own document template.
Content type can be created by the following
• from the rootweb of a site collection, go to Site Action > Site Settings > Galleries > Site content types
• using a feature
Q)What is the difference between Syncronous & Asyncronous events?
Syncronous calls ending with 'ing' E.g. ItemDeleting Event Handler code execute BEFORE action is committed WSS waits for code to return Option to cancel and return error code
Asyncronous calls ending with 'ed' E.g. ItemDeleted Event Handler code executes AFTER action is committed WSS does not wait for code to return Executed in its own Worker thread.
Q)How to query from multiple lists ?
Use SPSiteDataQuery to fetch data from multiple lists.
Q)What are the various kinds of roles the users can have?
A user can be assigned one of the following roles
    * Reader  : Has read-only access to the Web site.
    * Contributor :  Can add content to existing document libraries and lists.
    * Web Designer :  Can create lists and document libraries and customize pages in the Web site.
    * Administrator : Has full control of the Web site.
Q)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.
Q)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.
A SharePoint Feature is a functional component that can be activated and deactivate at various scopes throughout a SharePoint instances.
Scopes include
•        Farm
•        WebApplication
•        Site (site collection)
•        Web (site)
Features have their own receiver architecture, which allow you to trap events such as when a feature is
•        installing
•        uninstalling
•        activated
•        deactivated
The element types that can be defined by a feature include
•        menu commands
•        link commands
•        page templates
•        page instances
•        list definitions
•        list instances
•        event handlers
•        workflows
The two files that are used to define a feature are
•          feature.xml
•          manifest file(elements.xml)
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.
Common stsadm commands associated with feature are
•        stsadm -o installfeature
•        stsadm -o uninstallfeature
•        stsadm -o activatefeature
•        stsadm -o deactivatefeature
  ------------------
  Q)What types of SharePoint assets can be deployed with a SharePoint feature?
With Features we can do a lot. For example, you could deploy as follows
    * Simple site customizations
    * Custom site navigation
    * WebParts
    * pages
    * list types
    * list instances
    * event handlers
    * workflows
    * custom actions
Q)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 .
SPListEventReceiver, SPItemEventReciever, and SPWebEventReceiver inherit from the abstract base class SPEventReceiverBase.
SPWorkflowLibraryEventReceiver inherits from SPItemEventReceiver.
SPEmailEventReceiver inherits directly from System.Object
Q) What are the built in ways to backup a SharePoint install?
 
Through the central administration and the stsadm command
Q) What are the differences between the two base classes ?
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
 
Q) how can debugging share point application  ?
   1. build application place .dll into gac and reset iis
   2. On the Debug menu, select Attach to Process
   3. select the Show processes from all users check box.
   4. select W3Wp.exe can attach
   5. refresh sharepoint site point break point
 
Q) Difference SPSite and SPWeb object
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.
      SPSite rootSite = new SPSite("http://polashivaprasad-pc:1234/");
       SPWeb objWeb = rootSite.OpenWeb();
 
Q) How do you connect to a SharePoint list and insert a new List Item?
using(SPSite rootSite = new SPSite("http://polashivaprasad-pc:1234/"))
{
          using(SPWeb objWeb = mySite.OpenWeb())
          {
                   SPList interviewList = myWeb.Lists["listtoinsert"];
                   SPListItem newItem = interviewList.Items.Add();
                   newItem["interview"] = "interview";
                   newItem.Update();
          }
}
Q) 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?
          SPList interviewList = rootWeb.Lists["listtoiterate"];
          foreach (SPListItem interview  in interviewList)
          {
                   // Append the code as per your requirement
          }
 
Q) How could you append a string to the title of a site when it is provisioned?
In the OnActivated event:
          SPWeb objWeb = siteCollection.RootWeb;
          objWeb.Title += "polashivaprasad.com";
          objWeb.Update();
 
Q) What is the difference between SPListItem.SystemUpdate and SPListItem.Update Method
SPListItem.SystemUpdate:
Updates the database(Sharepoint list) with changes that are made to the list item, without effecting changes in the Modified Time or Modified By fields.
SPListItem.SystemUpdate Overloaded Method:
SPListItem.SystemUpdate():
Updates the database with changes made to the list item, without effecting changes in the Modified or Modified By fields.
SPListItem.SystemUpdate(Boolean):
Updates the database with changes that are made to the list item, without effecting changes in the Modified Time or Modified By fields, or optionally, the item version.
SPListItem.Update():
Updates the database(Sharepoint list) with changes that are made to the list item/new version of item, and changes in the Modified Time or Modified By fields.
//Take the reference of that item
          SPListItem listItem = listItemCOll[icount];
          listItem["FIRST_NAME"] = “pola”;
          listItem["LAST_NAME"] = “shiva”;
          listItem["EMAIL_ADDR"] = “polashivaprasad[at]gmail.com”;
          //Update the Item
          listItem.SystemUpdate(false);
//The argument false informs the SP object Model not increment versions.
          listItem.Update();