Search This Blog

Tuesday, December 14, 2010

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

1 comment:

  1. Hi

    Tks very much for post:

    I like it and hope that you continue posting.

    Let me show other source that may be good for community.

    Source: Office interview questions

    Best rgs
    David

    ReplyDelete