<?xml version="1.0" encoding="UTF-8" ?>

<rss version="2.0"
  xmlns:ent="http://www.purl.org/NET/ENT/1.0/"
  xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
  <title>Purushotam&#39;s Technology Blog</title>
  <link>http://www.purushotam.com/blog</link>
  <description></description>
  <language>en-us</language>
  <lastBuildDate>Thu, 02 Oct 2008 18:06:11 +0100</lastBuildDate>
  <category domain="http://www.purushotam.com/blog">Main Page</category>
  <generator>Blogware</generator>
  
  <item>
    <dc:creator>purushotam</dc:creator>
    <title>Updated Resume..</title>
    <link>http://www.purushotam.com/blog/_archives/2008/9/16/3887662.html</link>
    <guid>http://www.purushotam.com/blog/_archives/2008/9/16/3887662.html</guid>
    <pubDate>Tue, 16 Sep 2008 19:36:00 +0100</pubDate>
    <description>&lt;br&gt;</description>
    
    <category domain="http://www.purushotam.com/blog">Main Page</category>
    
    <category domain="http://www.purushotam.com/blog/Downloads/Resume">Resume</category>
    
    
    
    <enclosure url="http://www.purushotam.com/_attachments/3887662/Resume%20of%20Purushotam%20Tumkur%20(Sharepoint%20or%20C%23).doc" length="125440" type="application/msword" />
    
  </item>
  
  <item>
    <dc:creator>purushotam</dc:creator>
    <title>How to elevate Permissions for using Sharepoint Object model</title>
    <link>http://www.purushotam.com/blog/_archives/2008/7/5/3828509.html</link>
    <guid>http://www.purushotam.com/blog/_archives/2008/7/5/3828509.html</guid>
    <pubDate>Sat, 05 Jul 2008 20:16:00 +0100</pubDate>
    <description>Many of the operations you perform with the object model—even a simple listing—will require administrative permissions. This is because SharePoint applies security restrictions to the use of the object model. However, there are many times when you would like to display information—such as a site listing—to a user that does not have administrator rights. In these cases, you must utilize the &lt;span style=&quot;font-style: italic;&quot;&gt;SPSecurity &lt;/span&gt;class to temporarily run object model code with elevated permissions. These elevated permissions allow you to run code under the identity of the application pool account. &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; In order to run code with elevated permissions, you must encapsulate the code in a function that has no return value. You then create an instance of the &lt;span style=&quot;font-style: italic;&quot;&gt;CodeToRunElevated &lt;/span&gt;class using the name of the function as an argument. You can subsequently execute the code by calling the &lt;span style=&quot;font-style: italic;&quot;&gt;RunWithElevatedPrivileges &lt;/span&gt;method of the &lt;span style=&quot;font-style: italic;&quot;&gt;SPSecurity &lt;/span&gt;object and passing in the &lt;span style=&quot;font-style: italic;&quot;&gt;CodeToRunElevated &lt;/span&gt;object. Below shown is&amp;nbsp; an example that calls a method to list all of the available features in a farm.&lt;br&gt;&lt;br&gt;&amp;lt;%@ Page Language=&quot;C#&quot; MasterPageFile=&quot;~/_layouts/application.master&quot;%&amp;gt;&lt;br&gt;&amp;lt;%@ Assembly Name=&quot;Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C&quot; %&amp;gt;&lt;br&gt;&amp;lt;%@ Import Namespace=&quot;Microsoft.SharePoint&quot; %&amp;gt;&lt;br&gt;&amp;lt;%@ Import Namespace=&quot;Microsoft.SharePoint.WebControls&quot; %&amp;gt;&lt;br&gt;&amp;lt;asp:Content ID=&quot;Content4&quot; runat=&quot;server&quot;&lt;br&gt;ContentPlaceHolderID=&quot;PlaceHolderMain&quot;&amp;gt;&lt;br&gt;&amp;lt;%&lt;br&gt;SPSecurity.CodeToRunElevated myCode =&lt;br&gt;new SPSecurity.CodeToRunElevated(ShowFeatures);&lt;br&gt;SPSecurity.RunWithElevatedPrivileges(myCode);&lt;br&gt;%&amp;gt;&lt;br&gt;&amp;lt;/asp:Content&amp;gt;&lt;br&gt;&amp;lt;script language=&quot;C#&quot; runat=&quot;server&quot;&amp;gt;&lt;br&gt;protected void ShowFeatures()&lt;br&gt;{&lt;br&gt;//Code goes here&lt;br&gt;}&lt;br&gt;&amp;lt;/script&amp;gt; &lt;br&gt;</description>
    
    <category domain="http://www.purushotam.com/blog">Main Page</category>
    
    <category domain="http://www.purushotam.com/blog/SharePoint">SharePoint</category>
    
    
    <ent:cloud ent:href="">
    
    <ent:topic ent:id="RunWithElevatedPrivileges" ent:href="http://www.purushotam.com/blog/cmd=search_keyword/k=RunWithElevatedPrivileges">RunWithElevatedPrivileges</ent:topic>
    
    <ent:topic ent:id="elevation" ent:href="http://www.purushotam.com/blog/cmd=search_keyword/k=elevation">elevation</ent:topic>
    
    </ent:cloud>
    
    
    
  </item>
  
  <item>
    <dc:creator>purushotam</dc:creator>
    <title>How to create Simple Workflow in Sharepoint</title>
    <link>http://www.purushotam.com/blog/_archives/2008/6/28/3827077.html</link>
    <guid>http://www.purushotam.com/blog/_archives/2008/6/28/3827077.html</guid>
    <pubDate>Wed, 02 Jul 2008 19:46:00 +0100</pubDate>
    <description>In my last posting, i briefed about basics of Workflow in sharepoint and in this posting, we will take close look at implementation of it. &lt;img src=&quot;/_images/emoticons/em.icon.smile.gif&quot;&gt;&lt;br&gt;&lt;br&gt;To start with I will create a simple example workflow using SharePoint Designer. I am going to create a workflow for an imaginary company’s Human Resources department. They have placed an advertisement for a new C# developer and they expect a lot of letters and resumes. The CTO wants to read these letters and approve or decline them. If a letter is approved, the candidate will be invited for an interview. In this example, I am going to create the first part of the process:&amp;nbsp; namely, a document (the letter from the candidate) will be uploaded to a document library called LettersCandidates. This document library will contain two columns: Assigned to and Status. The custom column Assigned to will contain three values: CTO, CEO, and CFO. When a document is uploaded to the document&amp;nbsp; library and assigned to the CTO, the CTO will receive a new task in this Tasks list asking whether he approves or declines the document. The second custom column, Status, contains the following values: prospect, 1st interview, 2nd interview, declined, and hired.&lt;br&gt;&lt;br&gt;Follow these steps to create a new document library called LettersCandidates and a new column:&lt;br&gt;1. Open a SharePoint site where you want to create a new document library.&lt;br&gt;2. Click the View All Site Content link on the left of the SharePoint site. This opens the All Site&lt;br&gt;Content page.&lt;br&gt;3. Click Create. This opens the Create page.&lt;br&gt;4. Click Document Library in the Libraries section.&lt;br&gt;5. Name the document library LettersCandidates and click Create.&lt;br&gt;6. Select Settings in the LettersCandidates document library and click Create Column.&lt;br&gt;&lt;br&gt;7. Name the column Status, check the Choice radio button, and enter the values: prospect, 1st&lt;br&gt;interview, 2nd interview, declined, and hired. Click OK.&lt;br&gt;8. Click Create Column.&lt;br&gt;9. Name the column Assigned to, check the Choice radio button, and enter the values: CTO,&lt;br&gt;CEO, and CFO. Click OK.&lt;br&gt;&lt;br&gt;After setting up the LettersCandidates document library and adding a column, you are ready to open the SharePoint site in&amp;nbsp; SharePoint Designer. The next thing to do is to start designing the example workflow. Follow these steps to create the workflow.&lt;br&gt;&lt;br&gt;1. Open the SharePoint site containing the LettersCandidates document library in SharePoint Designer.&lt;br&gt;2. In the File menu, click New and select Workflow. This opens the Workflow Designer wizard.&lt;br&gt;3. In the Give a name to this workflow text box, specify the following name: Candidates Notification WF.&lt;br&gt;4. In the What SharePoint list should this workflow be attached to drop-down list, select the LettersCandidates document library.&lt;br&gt;5. In the Select workflow start options for items in LettersCandidates section, do the following.&lt;br&gt;&lt;br&gt;Uncheck the Allow this workflow to be manually started from an item check box. Check the Automatically start this workflow when an item is created check box and uncheck the Automatically start this workflow when an item is changed check box. This way the workflow will run each time an item is created. Following figure shows the first page of the Workflow Designer wizard.&lt;br&gt;&lt;br&gt;&lt;img src=&quot;/Articles/webpart_23.jpg&quot;&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;6. Click Next.&lt;br&gt;7. In the Step Name text box, specify the following name: AssignTaskStep.&lt;br&gt;8. Click the Conditions drop-down list and select Compare LettersCandidates Field. The condition if field equals value is inserted, where field and value are the parameters that must be filled in. &lt;br&gt;9. Click the field parameter and select the Assigned to column. The field parameter shows a drop-down list filled with the specified document library’s metadata. &lt;br&gt;10. Click the value parameter and select the CTO value. The value parameter shows a dropdown list filled with the values from the specified column. Figure 4-9 shows the value parameter’s drop-down list.&lt;br&gt;&lt;br&gt;&lt;img src=&quot;/Articles/webpart_24.jpg&quot;&gt;&lt;br&gt;&lt;br&gt;11. Click the Actions drop-down list and select Collect data from a user (output to variable:collect1). The action Collect data from this user is inserted, where data and this user are parameters that must be filled in. The parameter variable:collect1 will be where we save the data that is collected from the user.&lt;br&gt;12. Click data. This opens the Custom Task wizard. Click Next.&lt;br&gt;13. In the Name text box, specify the following name: ApprovalCTO. Click Next.&lt;br&gt;14. Click the Add button to define a custom task field that the user can fill out. This opens the Add Field dialog box.&lt;br&gt;15. In the Field name text box, specify the following name: DecisionCTO. In the Information type drop-down list, choose choice (menu to choose from). Click Next. &lt;br&gt;16. In the Choices list, enter the following two choices: Approve, Decline.&lt;br&gt;17. Uncheck the Allow fill-in choices check box. Click Finish twice.&lt;br&gt;18. Click this user. This opens the Select Users dialog box. Select a user from the list of users, click Add, and click OK. Figure below shows the AssignTaskStep workflow step.&lt;br&gt;&lt;br&gt;&lt;img src=&quot;/Articles/webpart_25.jpg&quot;&gt;&lt;br&gt;&lt;br&gt;19. Click Add workflow step. This adds a new workflow step to the workflow.&lt;br&gt;&lt;br&gt;20. In the Step Name text box, specify the following name: ChangeStatus.&lt;br&gt;21. Click the Conditions drop-down list and select Compare any data source. The condition if value equals value is inserted, where value and value are the parameters that must be filled in.&lt;br&gt;22. Click the display data binding icon next to the first value parameter. This opens the Define Workflow Lookup window. The Source drop-down list shows the SharePoint site’s available lists. The Field drop-down list shows all fields available in the specified list. In the Source drop-down list, select Tasks. In the Field drop-down list, select DecisionCTO. In the Value drop-down list, select Approve, as shown in Figure here..&lt;br&gt;&lt;br&gt;&lt;img src=&quot;/Articles/webpart_26.jpg&quot;&gt;&lt;br&gt;&lt;br&gt;23. Click OK.&lt;br&gt;24. Click the Actions drop-down list and select Set Field in Current Item. The action Set field to value is inserted, where field and value are parameters that must be filled in. Click the field parameter and select the Status value. The field parameter shows a drop-down list filled with the specified document library’s metadata.&lt;br&gt;25. Click the value parameter and select 1st interview. The value parameter shows a dropdown list filled with the values from the specified column. Below figure shows you the ChangeStatus workflow step.&lt;br&gt;&lt;img src=&quot;/Articles/webpart_27.jpg&quot;&gt;&lt;br&gt;&lt;br&gt;26. Click the Check Workflow button to check whether your workflow contains any errors.&lt;br&gt;27. Click Finish. The workflow is validated and associated with the document library. The next set of figures walks you through the example workflow in a SharePoint site. Figure below shows you a letter from Candidate A in the LettersCandidates document library. The Candidates Notification Workflow is in progress.&lt;br&gt;&lt;br&gt;&lt;img src=&quot;/Articles/webpart_28.jpg&quot;&gt;&lt;br&gt;&lt;br&gt;The workflow will assign a task to the CTO. This task will also be send as an e-mail to the CTO. The task can be edited and the CTO can approve or decline the document. This is shown in Figure.&lt;img src=&quot;/Articles/webpart_29.jpg&quot;&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;After the CTO has approved or declined the document, the status of the document will change. Take a look at figure..&lt;br&gt;&lt;br&gt;&lt;img src=&quot;/Articles/webpart_30.jpg&quot;&gt;&lt;br&gt;&lt;br&gt;....usssshhh... i think you might be tired by this time. take some rest or even a nap could be better and move on...&lt;img src=&quot;/_images/emoticons/em.icon.smile.gif&quot;&gt;&lt;br&gt;&lt;br&gt;let me see what i can do for next posting... until then bye..&lt;br&gt;&lt;br&gt;</description>
    
    <category domain="http://www.purushotam.com/blog">Main Page</category>
    
    <category domain="http://www.purushotam.com/blog/SharePoint">SharePoint</category>
    
    
    <ent:cloud ent:href="">
    
    <ent:topic ent:id="workflow" ent:href="http://www.purushotam.com/blog/cmd=search_keyword/k=workflow">workflow</ent:topic>
    
    <ent:topic ent:id="Sharepoint" ent:href="http://www.purushotam.com/blog/cmd=search_keyword/k=Sharepoint">Sharepoint</ent:topic>
    
    <ent:topic ent:id="in" ent:href="http://www.purushotam.com/blog/cmd=search_keyword/k=in">in</ent:topic>
    
    </ent:cloud>
    
    
    
  </item>
  
  <item>
    <dc:creator>purushotam</dc:creator>
    <title>Basics of Windows Workflow Foundation</title>
    <link>http://www.purushotam.com/blog/_archives/2008/6/28/3827107.html</link>
    <guid>http://www.purushotam.com/blog/_archives/2008/6/28/3827107.html</guid>
    <pubDate>Sat, 28 Jun 2008 17:16:00 +0100</pubDate>
    <description>SharePoint 2007 incorporates an infrastructure that supports the use of existing document-centric workflows as well as the creation of new document-centric workflows by either developers or information workers.&lt;br&gt;&lt;br&gt;&amp;nbsp;Windows Workflow Foundation (WF) forms the basis of the SharePoint 2007 workflow functionality. Windows Workflow Foundation is a part of the Microsoft .NET Framework 3.0.&lt;br&gt;&lt;br&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Note: &lt;/span&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;The Microsoft .NET Framework 3.0 was formerly known as WinFX. It adds four new technologies to the&lt;/span&gt;&lt;br style=&quot;font-style: italic;&quot;&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;.NET Framework 2.0: Windows Workflow Foundation, Windows Communication Foundation (WCF, formerly known&lt;/span&gt;&lt;br style=&quot;font-style: italic;&quot;&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;as Indigo), Windows Presentation Foundation (WPF, formerly known as Avalon), and Windows Cardspace (WCF,&lt;/span&gt;&lt;br style=&quot;font-style: italic;&quot;&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;formerly known as InfoCard).&lt;/span&gt;&lt;br&gt;&lt;br&gt;Windows Workflow Foundation is not a stand-alone application; instead, it has a run-time workflow engine that can execute short-term as well as persistable workflows. The Windows Workflow Foundation run time provides additional services that are important for executing workflows such as tracking, notifications, and transactions. &lt;br&gt;Any application or service can leverage WF workflow services by hosting WF in its process. SharePoint 2007 acts as a host for WF and adds a couple of custom implementations for workflow services as well.&lt;br&gt;&lt;br&gt;SharePoint 2007 offers two different tools for working with and creating workflows: SharePoint Designer 2007 and Visual Studio 2005 Designer. Both will be discussed in this chapter. SharePoint Designer 2007 is a great tool for creating ad hoc workflows. It places the tools to create workflows well within the grasp of normal information workers. Visual Studio 2005 Designer, on the other hand, allows developers to create advanced, enterprise-level workflows.&lt;br&gt;&lt;br&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Note&lt;/span&gt; &lt;span style=&quot;font-style: italic;&quot;&gt;Actually, you can associate a workflow created in SharePoint Designer with more than one list. The&lt;/span&gt;&lt;br style=&quot;font-style: italic;&quot;&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;auto-generated code contains hard-coded GUIDs representing a list. If you change those GUIDs, it is possible to&lt;/span&gt;&lt;br style=&quot;font-style: italic;&quot;&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;associate a workflow with another list.&lt;/span&gt;&lt;br&gt;&lt;br&gt;In the following sections, we will delve deeper into the concepts related to Windows Workflow Foundation.&lt;br&gt;Activities&lt;br&gt;I will begin by looking at the basic structure of a workflow. A workflow represents a business process that consists of a set of transactions which form a model to describe a real-world problem. Business transactions form the elementary building blocks of a business process. A business transaction involves two parties:&lt;br&gt;&lt;br&gt;• The initiator is responsible for starting a business transaction by issuing some sort of&lt;br&gt;request.&lt;br&gt;• The executor is responsible for performing some kind of action based on a request.&lt;br&gt;&lt;br&gt;Conceptually, the life cycle of a business transaction consists of three phases:&lt;br&gt;1. Order phase: This phase starts when the initiator makes a request for some kind of action to&lt;br&gt;be performed. This phase ends with a promise by the executor to perform that action.&lt;br&gt;2. Execution phase: In this phase, the executor performs the requested action. The action succeeds&lt;br&gt;or fails. Either way, a result is reached, thus ending this phase of the business transaction&lt;br&gt;life cycle.&lt;br&gt;3. Result phase: In this phase, the executor communicates which result was reached, which is&lt;br&gt;either accepted or rejected by the initiator.&lt;br&gt;In Windows Workflow Foundation, the abstract concept of business transactions (a concept that has meaning in the external world) is translated to activities (a concept that has meaning in the software world). Activities are the building blocks of a&amp;nbsp; workflow; every single step within a workflow requires an activity. Windows Workflow Foundation utilizes three different kinds of activities: &lt;br&gt;• Simple activity: A simple activity represents a simple action in its most basic form. An example of such a simple activity is the DelayActivity.&lt;br&gt;• Composite activity: A composite activity is an activity that aggregates one or more child activities within a single activity. An example of such a composite activity is the IfElse activity.&lt;br&gt;• Rule activity: A rule activity (also called a data-driven activity) drives the flow of a workflow. An example of this type of activity is the EventDriven activity.&lt;br&gt;&lt;br&gt;Out of the box, the Windows Workflow Foundation framework contains a set of activities that provide functionality for the creation of workflows that contain control flow, conditions, event handling, and state management, and are able to communicate with other applications and services. &lt;br&gt;&lt;br&gt;If you design a workflow, you can choose to make use of one of the activities belonging to this default set or you can create your own activities. Developers are free to create their own custom activity libraries and use them in other workflows. You can also use code activities to add custom code to a workflow. Code activities allow you to add basic behavior to a workflow; if you want complex behavior, such as the ability to create a composite activity that is able to contain other activities, you should create your own custom activity.&lt;br&gt;&lt;br&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Activities&lt;/span&gt; can be sequential, in which case the order of workflow actions is specified at design time. Alternatively, activities can be event-driven. In such scenarios, the order of workflow actions is determined at run time in response to external events. Each activity contains the following logic/data: &lt;br&gt;&lt;br&gt;• Metadata responsible for describing design time properties of the activity.&lt;br&gt;• Instance data describing the activity run-time state.&lt;br&gt;• Activity behavior in the form of programmed execution logic.&lt;br&gt;• Validation logic that can be used to validate activity metadata. This is optional.&lt;br&gt;&lt;br&gt;Following figure shows a basic workflow that consists of several activities and uses custom activity libraries.&lt;br&gt;&lt;br&gt;&lt;img src=&quot;/Articles/Workflow_1.jpg&quot;&gt;&lt;br&gt;&lt;br&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Components&lt;/span&gt;&lt;br&gt;Windows Workflow Foundation provides services as well as a framework and consists of the following&lt;br&gt;components (see Figure):&lt;br&gt;• Base activity library: This library contains all activities that are available out of the box.&lt;br&gt;Activities are essential building blocks for creating custom workflows and are discussed in the previous section, “Activities.”&lt;br&gt;• Runtime engine: The workflow runtime engine is able to interpret and execute workflows created using Windows Workflow Foundation. The runtime engine is also responsible for keeping track of workflow state.&lt;br&gt;• Runtime services: The WF workflow runtime engine can be hosted by different host applications, including SharePoint. This is a very flexible system, which is made possible via the workflow runtime services. The workflow runtime services are also&amp;nbsp; responsible for handling any communication between the host application and the workflow.&lt;br&gt;&lt;br&gt;&lt;img src=&quot;/Articles/Workflow_2.jpg&quot;&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Windows Workflow Foundation ships with a couple important tools that facilitate workflow creation: a visual designer and a debugger. &lt;br&gt;The workflow runtime engine is hosted in-process within a host application (never as a stand-alone process) and is responsible for creating and maintaining running workflow instances. For each application domain (in .NET, the fundamental process that executes code), there can be only one workflow runtime engine. A workflow runtime engine is able to run multiple workflow&lt;br&gt;instances concurrently. The runtime engine needs to be hosted by a host process, such as a console application, Windows form-based application, ASP.NET web site, or a web service. Because a workflow is hosted in-process, it can easily and efficiently communicate with its host application.&lt;br&gt;&lt;br&gt;The workflow runtime engine utilizes many WF services when a workflow instance runs. The following services are included in the runtime engine:&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;• Execution&lt;br&gt;• Tracking&lt;br&gt;• State management&lt;br&gt;• Scheduler&lt;br&gt;• Rules&lt;br&gt;&lt;/div&gt;Besides the runtime engine itself, WF contains multiple runtime services. Runtime services are pluggable, so applications can provide these services in unique ways within their execution environment.&lt;br&gt;&lt;br style=&quot;font-weight: bold;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Workflow Styles&lt;/span&gt;&lt;br&gt;Windows Workflow Foundation supports two styles of workflow: sequential and state machine. Before you start creating a workflow project, it is important to figure out what style of workflow you want to use.&lt;br&gt;&lt;br&gt;The sequential workflow style is used for repetitive operations such as designing a set of activities that must always be performed in the same order. The workflow follows the sequence until the last activity is completed, and the workflow always remains in control of what happens next. &lt;br&gt;&lt;br&gt;Such workflows are not necessarily entirely deterministic; you can use branching logic such as IfElseActivity activities or ParallelActivity activities and let the exact sequence of events vary. &lt;br&gt;For example, imagine you are creating a workflow that describes the process of installing software. This is a typical scenario where you always follow the steps one by one and in the same order.&lt;br&gt;Therefore, you can represent this process using a sequential workflow. The following figure shows an example.&lt;br&gt;&lt;br&gt;&lt;img src=&quot;/Articles/Workflow_3.jpg&quot;&gt;&lt;br&gt;&lt;br&gt;The state machine workflow style is used when you want to model your workflow as a state machine. State machine workflows are made up of different states, one being the starting state, which is the state that is entered once the workflow process begins. Each state can receive a certain set of events. Based on these events, the workflow can transition from one state to another&lt;br&gt;state. In state machine workflows, the end user is always in control. That is why this type of workflow is also known as a human-oriented workflow. It is not required to define a final state, but if you do happen to have a final state in a workflow and the transition is made to that state, the workflow will end.&lt;br&gt;&lt;br&gt;An example of a state machine workflow is an online shop where one state of the workflow process describes the situation where the customer can submit an order and wait for approval of the credit card data. Another state in the workflow process describes the situation where the customer, for the time being, is satisfied with selecting a couple of products and wants to place&lt;br&gt;the order at a later time. Therefore, each customer finds himself in one of the states in the workflow process and goes to another state depending on his choices. &lt;br&gt;&lt;br&gt;The following Figure shows a statemachine workflow.&lt;br&gt;&lt;img src=&quot;/Articles/Workflow_4.jpg&quot;&gt;&lt;br&gt;&lt;br&gt;Although you certainly can, you do not have to rush out and start creating your own workflows immediately, because, out of the box, SharePoint 2007 ships with a set of default workflows. They are..&lt;br&gt;&lt;br&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Approval : &lt;/span&gt;&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;This is probably the most basic and often-used workflows you can imagine. You can submit a document for approval; approvers can accept or reject a document or request changes.&lt;br&gt;&lt;/div&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Collect Feedback:&lt;/span&gt; &lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;Gathers feedback information from a group of reviewers.&lt;br&gt;&lt;/div&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Collect Signatures&lt;/span&gt;: &lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;Collects signatures from a group of approvers and requires the use of Microsoft Office clients.&lt;br&gt;&lt;/div&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Disposition Approval: &lt;/span&gt;&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;Centered on document expiration and retention.&lt;br&gt;&lt;/div&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Group Approval: &lt;/span&gt;&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;An advanced version of the Approval workflow.&lt;br&gt;&lt;/div&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Issue Tracking&lt;/span&gt;: &lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;Dedicated to an issue process involving tasks, task assignments, and task completion.&lt;br&gt;&lt;/div&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Translation Management:&lt;br&gt;&lt;/span&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/span&gt;Facilitates a translation process involving documents, tasks, and translators.&lt;br&gt;&lt;/div&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Three-state:&lt;br&gt;&lt;/span&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/span&gt;Tracks the status of an item through three states.&lt;br&gt;&lt;br&gt;In my next posting, we will take a close look at implementing workflow in sharepoint.&lt;br&gt;&lt;/div&gt;&lt;br&gt;&lt;br&gt;</description>
    
    <category domain="http://www.purushotam.com/blog">Main Page</category>
    
    <category domain="http://www.purushotam.com/blog/SharePoint">SharePoint</category>
    
    
    <ent:cloud ent:href="">
    
    <ent:topic ent:id="basics" ent:href="http://www.purushotam.com/blog/cmd=search_keyword/k=basics">basics</ent:topic>
    
    <ent:topic ent:id="Sharepoint" ent:href="http://www.purushotam.com/blog/cmd=search_keyword/k=Sharepoint">Sharepoint</ent:topic>
    
    <ent:topic ent:id="in" ent:href="http://www.purushotam.com/blog/cmd=search_keyword/k=in">in</ent:topic>
    
    <ent:topic ent:id="workflow" ent:href="http://www.purushotam.com/blog/cmd=search_keyword/k=workflow">workflow</ent:topic>
    
    </ent:cloud>
    
    
    
  </item>
  
  <item>
    <dc:creator>purushotam</dc:creator>
    <title>Using SPUserToken in Sharepoint (aka Impersonation in Sharepoint)</title>
    <link>http://www.purushotam.com/blog/_archives/2008/6/22/3827030.html</link>
    <guid>http://www.purushotam.com/blog/_archives/2008/6/22/3827030.html</guid>
    <pubDate>Sun, 22 Jun 2008 23:13:00 +0100</pubDate>
    <description>If you want to impersonate another user account to interact with the SharePoint object model, you can use the SPUserToken object. In Microsoft Office SharePoint Server 2007, several constructors of SPSite objects accept an SPUserToken object as one of the parameters to establish a different security context.&lt;br&gt;&lt;br&gt;To demonstrate the use of the SPUserToken object, I will programmatically check out a file on behalf of a different user. We have created a test document called Test.doc and uploaded it to the Shared Documents document library (as shown in fig below). Make sure that versioning is enabled on the Shared Documents document library. Later in this section, we will use the version history of this&lt;br&gt;document to check whether the code involving the SPUserToken object has succeeded.&lt;br&gt;&lt;br&gt;&lt;img src=&quot;/Articles/webpart_20.jpg&quot;&gt;&lt;br&gt;&lt;br&gt;In the next example, I will programmatically check out and then check in a document. I have created a web part called SuperPart that is responsible for doing this. The code retrieves the current site collection from the current SharePoint context and gets the PrivilegesTest SharePoint site from this site collection. By default, you are not allowed to check out and check in files in SharePoint using HTTP GET requests. To get around that, my code sample allows unsafe updates on the PrivilegesTest SharePoint site. An instance of SPFile associated with the test document can be retrieved from the PrivilegesTest SPWeb instance. Finally, the code adds some information to the test document’s versioning comment. The code responsible for checking out and checking in the&lt;br&gt;test document looks like this (it will be added to the Load event of a web part shortly):&lt;br&gt;&lt;br&gt;SPSite objSite = SPControl.GetContextSite(Context);&lt;br&gt;SPWeb objWeb = objSite.AllWebs[“PrivilegesTest”];&lt;br&gt;objWeb.AllowUnsafeUpdates = true;&lt;br&gt;SPFile objFile = objWeb.GetFile(“Shared Documents/Test.doc”);&lt;br&gt;objFile.CheckOut();&lt;br&gt;SPUser objUser = objFile.CheckedOutBy;&lt;br&gt;objFile.CheckIn(“check-in version: “ + objFile.UIVersion + å&lt;br&gt;“ by “ + objUser.Name);&lt;br&gt;&lt;br&gt;The complete code looks like this...&lt;br&gt;using System;&lt;br&gt;using System.Runtime.InteropServices;&lt;br&gt;using System.Web.UI;&lt;br&gt;using System.Web.UI.WebControls.WebParts;&lt;br&gt;using System.Xml.Serialization;&lt;br&gt;using Microsoft.SharePoint;&lt;br&gt;using Microsoft.SharePoint.WebControls;&lt;br&gt;using Microsoft.SharePoint.WebPartPages;&lt;br&gt;namespace KwikSliver.ImpersonationAndElevationDemo&lt;br&gt;{&lt;br&gt;[Guid(“47500629-54d5-4ac4-ac44-097b4ce2e3eb”)]&lt;br&gt;public class SuperPart : System.Web.UI.WebControls.WebParts.WebPart&lt;br&gt;{&lt;br&gt;public SuperPart()&lt;br&gt;{&lt;br&gt;this.ExportMode = WebPartExportMode.All;&lt;br&gt;}&lt;br&gt;protected override void OnLoad(EventArgs e)&lt;br&gt;{&lt;br&gt;SPSite objSite = SPControl.GetContextSite(Context);&lt;br&gt;SPWeb objWeb = objSite.AllWebs[“PrivilegesTest”];&lt;br&gt;objWeb.AllowUnsafeUpdates = true;&lt;br&gt;SPFile objFile = objWeb.GetFile(“Shared Documents/Test.doc”);&lt;br&gt;objFile.CheckOut();&lt;br&gt;SPUser objUser = objFile.CheckedOutBy;&lt;br&gt;objFile.CheckIn(“check-in version: “ + objFile.UIVersion + “ by “ +&lt;br&gt;objUser.Name);&lt;br&gt;}&lt;br&gt;}&lt;br&gt;}&lt;br&gt;&lt;br&gt;In this example, I first navigated to a page containing the SuperPart web part while logged in as user SuperB. This caused the SuperPart web part to load and execute, which checked out and then checked in a document in a document library under the SuperB system account. Then, I logged in as user NormalA and went back to the same page, causing the creation of a new version of Test.doc under the identity of NormalA. Figure down below shows the version history of the test document.&lt;br&gt;&lt;br&gt;The version history can be used to check our results. As you can see, the document was first updated by a system account, followed by an update by the NormalA user.&lt;br&gt;&lt;br&gt;&lt;img src=&quot;/Articles/webpart_21.jpg&quot;&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Now we are ready to show how to impersonate a user account using the SPUserToken object. We will access the default page of the PrivilegesTest site while logged in as SuperB, but we will check out and check in the file using the NormalB account. To make it easier to concentrate on the impersonation part of the code, copy the code concerning document modification to a new private&amp;nbsp; method called CheckInAndOut() in the web part.&lt;br&gt;&lt;br&gt;First, the web part needs to retrieve a valid SPUser object from the current SharePoint site representing the NormalB user account. We will use the AllUsers collection of the current SharePoint site to retrieve the NormalB user account. Then, we will need to create an instance of an SPSite object in the context of the NormalB user account. This is done by passing a valid user token representing&lt;br&gt;the NormalB user account. This token is retrieved from a property called UserToken that is a member of an SPUser object. The UserToken object needs to be passed to an SPSite object’s constructor in order to impersonate a given user. This is shown in the following code fragment: &lt;br&gt;&lt;br&gt;SPUser user = web.AllUsers[@”web1\NormalB”];&lt;br&gt;SPSite objSite = new SPSite(“http://web1”, user.UserToken);&lt;br&gt;The complete code for the web&amp;nbsp; part that uses the NormalB account to check out and then check in a document is listed here..&lt;br&gt;&lt;br&gt;using System;&lt;br&gt;using System.Runtime.InteropServices;&lt;br&gt;using System.Web.UI;&lt;br&gt;using System.Web.UI.WebControls.WebParts;&lt;br&gt;using System.Xml.Serialization;&lt;br&gt;using Microsoft.SharePoint;&lt;br&gt;using Microsoft.SharePoint.WebControls;&lt;br&gt;using Microsoft.SharePoint.WebPartPages;&lt;br&gt;namespace KwikSilver.ImpersonationAndElevationDemo&lt;br&gt;{&lt;br&gt;[Guid(“47500629-54d5-4ac4-ac44-097b4ce2e3eb”)]&lt;br&gt;public class SuperPart : System.Web.UI.WebControls.WebParts.WebPart&lt;br&gt;{&lt;br&gt;public SuperPart()&lt;br&gt;{&lt;br&gt;this.ExportMode = WebPartExportMode.All;&lt;br&gt;}&lt;br&gt;protected override void CreateChildControls()&lt;br&gt;{&lt;br&gt;try&lt;br&gt;{&lt;br&gt;string strValue = String.Empty;&lt;br&gt;SPSite site = SPControl.GetContextSite(Context);&lt;br&gt;SPWeb web = site.AllWebs[“PrivilegesTest”];&lt;br&gt;SPUser user = web.AllUsers[@”web1\NormalB”];&lt;br&gt;CheckInAndOut(user);&lt;br&gt;}&lt;br&gt;catch (Exception err)&lt;br&gt;{&lt;br&gt;Controls.Add(new LiteralControl(err.Message));&lt;br&gt;}&lt;br&gt;}&lt;br&gt;&lt;br&gt;private void CheckInAndOut(SPUser user)&lt;br&gt;{&lt;br&gt;SPSite objSite = new SPSite(“http://web1”, å&lt;br&gt;user.UserToken);&lt;br&gt;SPWeb objWeb = objSite.AllWebs[“PrivilegesTest”];&lt;br&gt;objWeb.AllowUnsafeUpdates = true;&lt;br&gt;SPFile objFile = objWeb.GetFile(“Shared Documents/Test.doc”);&lt;br&gt;objFile.CheckOut();&lt;br&gt;SPUser objUser = objFile.CheckedOutBy;&lt;br&gt;objFile.CheckIn(“check-in version: “ + objFile.UIVersion + “ by “ +&lt;br&gt;objUser.Name);&lt;br&gt;Controls.Add(new LiteralControl(objFile.Name +&lt;br&gt;“ checked out by: “ + objUser.Name));&lt;br&gt;}&lt;br&gt;}&lt;br&gt;}&lt;br&gt;&lt;br&gt;The result of executing this web part is shown in Figure below:&lt;br&gt;&lt;br&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;/webpart_22.jpg&quot;&gt;&lt;br&gt;&lt;br&gt;&lt;div style=&quot;text-align: left;&quot;&gt;It does not matter which account you use to log in to the SharePoint site containing the SuperPart web part; the web part uses the SPUserToken object to impersonate the NormalB account and then checks out test.doc using this account. You can also use the document version history to check this.&lt;br&gt;&lt;br&gt;In this posting, you have learned how to use the SharePoint SPUserToken object. We have used the SPUserToken object to add a new version to the version history of a document stored in a SharePoint list.&lt;br&gt;&lt;/div&gt;&lt;/div&gt;&lt;br&gt;&lt;br&gt;</description>
    
    <category domain="http://www.purushotam.com/blog">Main Page</category>
    
    <category domain="http://www.purushotam.com/blog/SharePoint">SharePoint</category>
    
    
    <ent:cloud ent:href="">
    
    <ent:topic ent:id="SPUserToken" ent:href="http://www.purushotam.com/blog/cmd=search_keyword/k=SPUserToken">SPUserToken</ent:topic>
    
    <ent:topic ent:id="impersonation" ent:href="http://www.purushotam.com/blog/cmd=search_keyword/k=impersonation">impersonation</ent:topic>
    
    </ent:cloud>
    
    
    
  </item>
  
  <item>
    <dc:creator>purushotam</dc:creator>
    <title>How to implement WCF service in Sharepoint 2007</title>
    <link>http://www.purushotam.com/blog/_archives/2008/6/11/3826987.html</link>
    <guid>http://www.purushotam.com/blog/_archives/2008/6/11/3826987.html</guid>
    <pubDate>Wed, 11 Jun 2008 21:43:00 +0100</pubDate>
    <description>In this posting, you will learn how to implement a WCF service that uses the application pool identity to connect to Microsoft Office SharePoint Server 2007.&lt;br&gt;&lt;br&gt;The example in this section is created using Visual Studio 2008.&lt;br&gt;In the example we will discuss in this section, we will create a WCF service that is hosted by Internet Information Server. Then, we will specify an application pool identity and use that in our impersonation scenario to run some code the end user is normally not allowed to execute. In the next procedure, you will see how to create a new virtual directory for a WCF service.&lt;br&gt;&lt;br&gt;In the next procedure, you will see how to create a new virtual directory for a WCF service.&lt;br&gt;1. Create a new folder at the following location: C:\Inetpub\wwwroot\TestWCFHost.&lt;br&gt;2. Open a command prompt and type inetmgr. This opens Internet Information Services (IIS)&lt;br&gt;Manager.&lt;br&gt;3. Expand the [server name] (local computer) node.&lt;br&gt;4. Expand the Web Sites node.&lt;br&gt;5. Locate a SharePoint web site where you want to add a virtual directory for your custom WCF&lt;br&gt;service, right-click it, and choose New äVirtual Directory. This opens the Virtual Directory&lt;br&gt;Creation Wizard.&lt;br&gt;6. Click Next.&lt;br&gt;7. Enter the following alias: TestWCFHost.&lt;br&gt;8. Click Next.&lt;br&gt;9. Enter the following path: C:\Inetpub\wwwroot\TestWCFHost.&lt;br&gt;10. Click Next.&lt;br&gt;11. Accept the default Virtual Directory Access Permissions and click Next.&lt;br&gt;12. Click Finish.&lt;br&gt;13. Right-click the newly created TestWCFHost node and choose Properties. This opens the&lt;br&gt;TestWCFHost Properties window.&lt;br&gt;14. Click Create.&lt;br&gt;15. Click OK.&lt;br&gt;&lt;br&gt;We will create a custom application pool for this virtual directory, specify an application pool&lt;br&gt;identity under which the server will run, and associate them with each other. This is explained in the&lt;br&gt;next procedure.&lt;br&gt;1. In Internet Information Services (IIS) Manager, right-click the Application Pools node and&lt;br&gt;choose New Application Pool. This opens the Add New Application Pool dialog window.&lt;br&gt;2. Specify the following Application pool ID: WCFAppPool.&lt;br&gt;3. Click OK.&lt;br&gt;4. Right-click the newly created WCFAppPool node and choose Properties. This opens the&lt;br&gt;WCFAppPool Properties window.&lt;br&gt;5. Click the Identity tab.&lt;br&gt;6. Select the Configurable radio button.&lt;br&gt;7. Specify a user name and password.&lt;br&gt;8. Click OK.&lt;br&gt;9. Right-click the previously created TestWCFHost virtual directory (located under the Web&lt;br&gt;Site node) and choose Properties. This opens the TestWCFHost Properties window.&lt;br&gt;10. In the Application pool drop-down list, choose WCFAppPool.&lt;br&gt;11. Click OK.&lt;br&gt;&lt;br&gt;At this point, you have created the container that will hold the WCF service. Now, we will use&lt;br&gt;Visual Studio 2008 to create the WCF service. This is discussed in the following procedure:&lt;br&gt;1. Start Visual Studio 2008 &lt;br&gt;2. Click File New Web Site. This opens the New Web Site dialog window.&lt;br&gt;3. In the Templates section, choose WCF service.&lt;br&gt;4. Select HTTP from the Location drop-down list.&lt;br&gt;5. In the Location text box, type the URL of the virtual directory you created earlier in this section.&lt;br&gt;In our case, this is http://[sharepoint web application]/TestWCFHost.&lt;br&gt;&lt;br&gt;As a result, several default files are created automatically. Delete the following files: Service.svc,&lt;br&gt;App_Code\Service.cs, and App_Code\IService.cs. You will notice that creating a WCF service is quite&lt;br&gt;similar to creating a classic .asmx web service. The following procedure discusses creating a WCF&lt;br&gt;service:&lt;br&gt;1. Right-click your project and choose Add New Item. This opens the Add New Item – [URL WCF service host] dialog window.&lt;br&gt;2. In the Templates section, choose WCF Service.&lt;br&gt;3. Enter the following name: MyWCFService.svc.&lt;br&gt;4. Ensure that the selected Language drop-down list is set to Visual C#.&lt;br&gt;5. Click Add.&lt;br&gt;This creates three files: MyWCFService.svc (located in the root of the project), and&amp;nbsp; IMyWCFService.cs and MyWCFService.cs (both located in the App_Code folder). The MyWCFService.svc file contains of a single line of code that refers to a code-behind file.&lt;br&gt;&lt;br&gt;and here is the file..&lt;br&gt;&lt;br&gt;&amp;lt;%@ ServiceHost Language=”C#” Debug=”true” Service=”KwikSilver.MyWCFService” CodeBehind=”~/App_Code/MyWCFService.cs” %&amp;gt;&lt;br&gt;&lt;br&gt;Next, we will take a closer look at the IMyWCFService class file. In WCF, all services expose contracts&lt;br&gt;that explicitly define what a service does. There are four different types of contracts:&lt;br&gt;• Service contracts that describe the operations that can be performed by the client.&lt;br&gt;• Data contracts that describe the data that is passed to and from the service.&lt;br&gt;• Fault contracts that describe errors that are raised by the service.&lt;br&gt;• Message contracts that describe how a service can interact directly with a message.&lt;br&gt;&lt;br&gt;In this example, only service contracts are relevant. You can create a service contract by adding a .cs file that defines a new interface. Then, you need to decorate the interface with a [ServiceContract] attribute that exposes a normal CLR interface as a WCF contract. Every method within such an interface that needs to be exposed in the WCF contract needs to be decorated&lt;br&gt;with the [OperationContract] attribute. code below shows the implementation for the IMyWCFService WCF service contract:&lt;br&gt;&lt;br&gt;using System;&lt;br&gt;using System.Collections.Generic;&lt;br&gt;using System.Runtime.Serialization;&lt;br&gt;using System.ServiceModel;&lt;br&gt;using System.Text;&lt;br&gt;namespace KwikSilver&lt;br&gt;{&lt;br&gt;[ServiceContract]&lt;br&gt;public interface IMyWCFService&lt;br&gt;{&lt;br&gt;[OperationContract]&lt;br&gt;string DoWork();&lt;br&gt;}&lt;br&gt;}&lt;br&gt;&lt;br&gt;This service contract needs to be implemented by a class. To demonstrate that impersonation has worked, we will use a piece of code that fails if the identity executing the code is not an administrator. The code retrieves the current SharePoint site and shows the collection of site groups of which the current user is a member:&lt;br&gt;&lt;br&gt;string strValue = String.Empty;&lt;br&gt;RevertToSelf();&lt;br&gt;SPWeb objCurrentWeb = SPControl.GetContextWeb(Context);&lt;br&gt;foreach (SPRole objRole in objCurrentWeb.CurrentUser.Roles)&lt;br&gt;{&lt;br&gt;strValue += “Role: “ + objRole.Name + “&amp;lt;br/&amp;gt;”;&lt;br&gt;}&lt;br&gt;&lt;br&gt;This code fails unless you are an administrator. If we modify the code a bit so you can pass the URL of the site collection and the user name as arguments, the code looks like this:&lt;br&gt;&lt;br&gt;public string GetUserRoles(string strUrl, string strUserName)&lt;br&gt;{&lt;br&gt;string strResult = String.Empty;&lt;br&gt;using (SPSite objSiteCollection = new SPSite(strUrl))&lt;br&gt;{&lt;br&gt;using (SPWeb objSite = objSiteCollection.OpenWeb())&lt;br&gt;{&lt;br&gt;SPUser objUser = objSite.Users[strUserName];&lt;br&gt;foreach (SPRole objRole in objUser.Roles)&lt;br&gt;{&lt;br&gt;strResult += objRole.Name + “, “;&lt;br&gt;}&lt;br&gt;}&lt;br&gt;}&lt;br&gt;return strResult;&lt;br&gt;}&lt;br&gt;&lt;br&gt;and finally here is the complete code..&lt;br&gt;&lt;br&gt;using System;&lt;br&gt;using System.Collections.Generic;&lt;br&gt;using System.Runtime.Serialization;&lt;br&gt;using System.ServiceModel;&lt;br&gt;using System.Text;&lt;br&gt;using System.Security.Principal;&lt;br&gt;using Microsoft.SharePoint;&lt;br&gt;&lt;br&gt;namespace KwikSilver&lt;br&gt;{&lt;br&gt;public class MyWCFService : IMyWCFService&lt;br&gt;{&lt;br&gt;public string DoWork()&lt;br&gt;{&lt;br&gt;// e.g. SHAREPOINT\system as the user name.&lt;br&gt;return GetUserRoles(“[site collection URL]”, @”[user name] “);&lt;br&gt;}&lt;br&gt;public string GetUserRoles(string strUrl, string strUserName)&lt;br&gt;{&lt;br&gt;try&lt;br&gt;{&lt;br&gt;string strResult = String.Empty;&lt;br&gt;using (SPSite objSite = new SPSite(strUrl))&lt;br&gt;{&lt;br&gt;using (SPWeb objWeb = objSite.OpenWeb())&lt;br&gt;{&lt;br&gt;SPUser objUser = objWeb.Users[strUserName];&lt;br&gt;foreach (SPRole objRole in objUser.Roles)&lt;br&gt;{&lt;br&gt;strResult += objRole.Name + “, “;&lt;br&gt;}&lt;br&gt;}&lt;br&gt;}&lt;br&gt;return strResult;&lt;br&gt;}&lt;br&gt;catch (Exception err)&lt;br&gt;{&lt;br&gt;return err.Message;&lt;br&gt;}&lt;br&gt;}&lt;br&gt;}&lt;br&gt;}&lt;br&gt;&lt;br&gt;Before you can use the WCF service, you need to adjust the web.config file to define endpoints that can be accessed by a client. This is done by adding a new &amp;lt;service&amp;gt; element to the &amp;lt;services&amp;gt; node of the web.config file. The &amp;lt;service&amp;gt; element allows you to define the service name via the name property. You can also add an &amp;lt;endpoint&amp;gt; element that defines a service contract that is used&lt;br&gt;for the WCF service (service contracts were discussed earlier in this chapter) and a binding that is used by the service. Bindings define aspects about the transport mechanism, such as the protocol or the message encoding type that are used. In this example, we will use WsHttpBinding, which uses HTTP as the transport protocol. The following code fragment shows how to define a new service endpoint that uses the IWcfImpersonator service contract and uses HTTP as the transport protocol:&lt;br&gt;&lt;br&gt;&amp;lt;service name=”KwikSilver.MyWCFService”&amp;gt;&lt;br&gt;&amp;lt;endpoint address=”” binding=”wsHttpBinding” contract=”KwikSilver.IMyWCFService” /&amp;gt;&lt;br&gt;&amp;lt;/service&amp;gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;You will also need to make sure that the WCF service emits metadata that is used by the client to retrieve a service description. You can do this by defining a service behavior for the service. Service behaviors affect all endpoints of a service, and you can specify which service behavior applies to a service by using the &amp;lt;service&amp;gt; element’s behaviorConfiguration attribute. This is shown in the&lt;br&gt;following code fragment:&lt;br&gt;&lt;br&gt;&amp;lt;service name=”KwikSilver.MyWCFService” behaviorConfiguration=”MyServiceTypeBehaviors”&amp;gt;&lt;br&gt;&lt;br&gt;The following service behavior needs to be added to the &amp;lt;serviceBehaviors&amp;gt; section of the web.config file, and specifies that any service associated to this behavior exposes metadata: &lt;br&gt;&amp;lt;behavior name=”MyServiceTypeBehaviors” &amp;gt;&lt;br&gt;&amp;lt;serviceMetadata httpGetEnabled=”true” /&amp;gt;&lt;br&gt;&amp;lt;/behavior&amp;gt;&lt;br&gt;&lt;br&gt;If you open a browser and browse to the svc file (http://[sharepoint web application]/TestWCFService/MyWCFService.svc), you should see a page similar to figure..&lt;br&gt;&lt;br&gt;&lt;img src=&quot;/Articles/webpart_18.jpg&quot;&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;The next procedure explains how to create a test client for this WCF service.&lt;br&gt;1. Right-click the solution and choose Add New Project. This opens the Add New Project dialog window.&lt;br&gt;2. In the Templates section, choose Windows Forms Application.&lt;br&gt;3. Enter the following Name: WCFTestClient.&lt;br&gt;4. Click OK.&lt;br&gt;5. Right-click the WCFTestClient project and choose Add Service Reference. The Add Service Reference dialog window appears.&lt;br&gt;6. In the Service URI text box, enter the URL of the MyWCFService.svc file. This is shown in figure..&lt;br&gt;&lt;br&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;/Articles/webpart_19.jpg&quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;br&gt;7. In the Service reference name text box, enter a friendly name that represents the service. In this case, I have specified a value of MyWCFServiceReference.&lt;br&gt;8. Click OK.&lt;br&gt;9. Open the code view window of the Windows form and add the code above to the Form load event:&lt;br&gt;&lt;br&gt;private void Form1_Load(object sender, EventArgs e)&lt;br&gt;{&lt;br&gt;MyWCFServiceReference.MyWCFServiceClient objService = å&lt;br&gt;new MyWCFServiceReference.MyWCFServiceClient();&lt;br&gt;string strResult = objService.DoWork();&lt;br&gt;objService.Close();&lt;br&gt;}&lt;br&gt;&lt;br&gt;You have now created a test client for your WCF service. Try it out and if everything works fine, you can add a service reference to this WCF service within web parts or SharePoint pages. In this section, you learned how to create a WCF service that is hosted in IIS and runs under a custom application pool identity.WCF services can be used to execute code under this custom&lt;br&gt;application pool identity that a normal end user would not be allowed to run.&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</description>
    
    <category domain="http://www.purushotam.com/blog">Main Page</category>
    
    <category domain="http://www.purushotam.com/blog/SharePoint">SharePoint</category>
    
    <category domain="http://www.purushotam.com/blog/WCF">WCF</category>
    
    
    <ent:cloud ent:href="">
    
    <ent:topic ent:id="Sharepoint" ent:href="http://www.purushotam.com/blog/cmd=search_keyword/k=Sharepoint">Sharepoint</ent:topic>
    
    <ent:topic ent:id="in" ent:href="http://www.purushotam.com/blog/cmd=search_keyword/k=in">in</ent:topic>
    
    <ent:topic ent:id="service" ent:href="http://www.purushotam.com/blog/cmd=search_keyword/k=service">service</ent:topic>
    
    <ent:topic ent:id="WCF" ent:href="http://www.purushotam.com/blog/cmd=search_keyword/k=WCF">WCF</ent:topic>
    
    </ent:cloud>
    
    
    
  </item>
  
  <item>
    <dc:creator>purushotam</dc:creator>
    <title>How to deploy webpart using solution package in Sharepoint 2007</title>
    <link>http://www.purushotam.com/blog/_archives/2008/6/5/3826918.html</link>
    <guid>http://www.purushotam.com/blog/_archives/2008/6/5/3826918.html</guid>
    <pubDate>Thu, 05 Jun 2008 18:58:00 +0100</pubDate>
    <description>In earlier versions for Sharepoint, biggest challenge was deploying webparts on production servers. But this is now easy and peezy with Sharepoint 2007... hats off to the new version!. In this posting i will demonstrate how can one aciveve deploying devleoped webparts easily.&lt;br&gt;&lt;br&gt;If you want to deploy a web part, you can use SharePoint solution files. Basically, SharePoint solution files are cabinet files (.cab) with a different extension, namely .wsp. When you use Visual Studio 2005 extensions for Windows SharePoint Services 3.0 to create a web part, as was discussed in my prevuois postings, a web part solution file is created automatically for you. In this section, you will learn how to create a SharePoint solution file that allows you to deploy a web part to other SharePoint servers and/or SharePoint web applications.&lt;br&gt;&lt;br&gt;To demonstrate web part deployment, we will create a new web part called MyWebPart.cs that uses the ASP.NET 2.0 Wizard control to implement a wizard. The Wizard server control enables you to build a sequence of steps that are displayed to the end user. You could use the Wizard control to either display or gather information in small steps. The Wizard control lets you define a group of views in which only one view at a time is active and is rendered to the client. Each view consists of four zones: sidebar, header, content, and navigation. The optional sidebar part contains an overview of all the steps in the wizard. The header contains the header information. The content part contains whichever control or controls you like. The navigation part consists of buttons to&lt;br&gt;navigate through the steps in the wizard.&lt;br&gt;&lt;br&gt;When you are constructing a step-by-step process that includes logic for every step taken, use the Wizard control to manage the entire process. The Wizard control’s navigation buttons fire server-side events whenever the user clicks one of the buttons, helping to navigate to other wizard views on the same page. Navigation can be linear and nonlinear; in other words, you can jump from&lt;br&gt;one view to another or navigate randomly to whichever view you like. All the controls in a wizard view are part of the page, so you can access them in code using their control IDs. &lt;br&gt;&lt;br&gt;In this example, I have defined six different steps. Each step is a WizardStep control and contains a text box. The state of the text boxes in the wizard is maintained automatically. The order in which the steps are defined is completely based upon the order in which they are added to the wizard via the Add() method of the Wizard object’s WizardSteps property. The WizardSteps property contains a collection of WizardSteps. Changing this order changes the order in which the end user sees them. The following figure shows the first step.&lt;br&gt;&lt;br&gt;&lt;img src=&quot;/Articles/webpart_11.jpg&quot;&gt;&lt;br&gt;&lt;br&gt;The first step, the start step, always has one button called Next. The following steps will have two buttons, as seen in Figure below:&lt;br&gt;&lt;br&gt;&lt;img src=&quot;/Articles/webpart_12.jpg&quot;&gt;&lt;br&gt;&lt;br&gt;There are six steps in this example. The final step, step 6, has a Previous and a Finish button, as you can see in Figure below:&lt;br&gt;&lt;br&gt;&lt;img src=&quot;/Articles/webpart_13.jpg&quot;&gt;&lt;br&gt;&lt;br&gt;The MyWebPart web part creates a very simple wizard; the Wizard control itself has a lot more options that I will not cover in this posting (sometime later!). The code for the web part using the Wizard control is shown in fig below:&lt;br&gt;&lt;br&gt;using System;&lt;br&gt;using System.Runtime.InteropServices;&lt;br&gt;using System.Web.UI;&lt;br&gt;using System.Web.UI.WebControls;&lt;br&gt;using System.Web.UI.WebControls.WebParts;&lt;br&gt;using System.Xml.Serialization;&lt;br&gt;using Microsoft.SharePoint;&lt;br&gt;using Microsoft.SharePoint.WebControls;&lt;br&gt;using Microsoft.SharePoint.WebPartPages;&lt;br&gt;namespace KwikSilver.Sharepoint.WebpartDemo&lt;br&gt;{&lt;br&gt;[Guid(“3d82fb59-c294-497d-9d47-d85c21540b06”)]&lt;br&gt;public class MyWebPart : System.Web.UI.WebControls.WebParts.WebPart&lt;br&gt;{&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;public MyWebPart()&lt;br&gt;{&lt;br&gt;}&lt;br&gt;protected override void CreateChildControls()&lt;br&gt;{&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;Wizard objWizard = new Wizard();&lt;br&gt;objWizard.HeaderText = “Wizard Header”;&lt;br&gt;for (int i = 1; i &amp;lt;= 6; i++)&lt;br&gt;{&lt;br&gt;WizardStepBase objStep = new WizardStep();&lt;br&gt;objStep.ID = “Step” + i;&lt;br&gt;objStep.Title = “Step “ + i;&lt;br&gt;TextBox objText = new TextBox();&lt;br&gt;objText.ID = “Text” + i;&lt;br&gt;objText.Text = “Value for step “ + i;&lt;br&gt;objStep.Controls.Add(objText);&lt;br&gt;objWizard.WizardSteps.Add(objStep);&lt;br&gt;}&lt;br&gt;Controls.Add(objWizard);&lt;br&gt;}&lt;br&gt;&lt;/div&gt;}&lt;br&gt;&lt;/div&gt;}&lt;br&gt;&lt;br&gt;Now that we have created a web part, we are ready for the next step, the creation of a SharePoint solution file. &lt;br&gt;In the first part of the process, we will add a manifest file (Manifest.xml) to our web part library solution. The manifest file is used by Visual Studio 2005 and defines how to populate the cabinet file that is used to deploy the MyWebPart web part. The next&amp;nbsp; procedure explains how to create a Manifest.xml file and how to add IntelliSense support to it:&lt;br&gt;&lt;br&gt;1. In the WebpartDemo project, choose Add äNew Item. This opens the Add New Item -&lt;br&gt;WebpartDemodialog box.&lt;br&gt;2. In the Templates section, choose XML file.&lt;br&gt;3. In the Name text box, add the following value: Manifest.xml.&lt;br&gt;4. Click the Add button.&lt;br&gt;5. Click the Code window of Manifest.xml.&lt;br&gt;6. In the Properties window, click Schemas.&lt;br&gt;7. Click the ... button. This opens the XSD Schemas dialog box.&lt;br&gt;8. Click the Add button. This opens the Open XSD Schema dialog box.&lt;br&gt;9. Locate wss.xsd ([drive letter]:\Program Files\Common Files\Microsoft Shared\web server&lt;br&gt;extensions\12\TEMPLATE\XML) and choose Open.&lt;br&gt;10. Click OK.&lt;br&gt;11. Add the code shown below to Manifest.xml:&lt;br&gt;&lt;br&gt;&amp;lt;?xml version=”1.0” encoding=”utf-8” ?&amp;gt;&lt;br&gt;&amp;lt;Solution xmlns=&quot;http://schemas.microsoft.com/sharepoint/&quot;&lt;br&gt;SolutionId=&quot;312ae869-37dc-4a74-9ecc-359fb3c1461d&quot;&amp;gt;&lt;br&gt;&amp;lt;Assemblies&amp;gt;&lt;br&gt;&amp;lt;Assembly DeploymentTarget=”WebApplication”&lt;br&gt;Location=”WebpartDemo.dll”&amp;gt;&lt;br&gt;&amp;lt;SafeControls&amp;gt;&lt;br&gt;&amp;lt;SafeControl Assembly=”WebpartDemo,&lt;br&gt;Version=1.0.0.0,&lt;br&gt;Culture=neutral,&lt;br&gt;PublicKeyToken=9f4da00116c38ec5”&lt;br&gt;Namespace=”KwikSilver.Sharepoint.WebpartDemo”&lt;br&gt;TypeName=”*”&lt;br&gt;Safe=”True” /&amp;gt;&lt;br&gt;&amp;lt;/SafeControls&amp;gt;&lt;br&gt;&amp;lt;/Assembly&amp;gt;&lt;br&gt;&amp;lt;/Assemblies&amp;gt;&lt;br&gt;&amp;lt;/Solution&amp;gt;&lt;br&gt;&lt;br&gt;After adding the Manifest.xml file to the web part library project, you can go ahead and create a&lt;br&gt;cabinet project to deploy the MyWebPart web part to another SharePoint server or SharePoint web&lt;br&gt;application. The next procedure explains how to create a SharePoint solution file:&lt;br&gt;1. Open the WebpartDemo web part library solution.&lt;br&gt;2. Choose File Add&amp;nbsp; New Project. This opens the Add New Project dialog box.&lt;br&gt;3. In the Project types section, expand the Other Project Types node and choose Setup and&lt;br&gt;Deployment.&lt;br&gt;4. In the Templates section, choose CAB Project.&lt;br&gt;5. In the Name text box, add the following value: WebpartDemoCab.&lt;br&gt;6. Click OK.&lt;br&gt;7. Right-click WPLibraryCab and choose Add äProject Output. This opens the Add Project&lt;br&gt;Output Group dialog box.&lt;br&gt;8. In the Project drop-down list, choose WebpartDemo.&lt;br&gt;9. Select Primary output and Content Files.&lt;br&gt;10. Click OK.&lt;br&gt;11. Build WebpartDemoCab.&lt;br&gt;12. Locate WebpartDemoCab.cab and rename it to WebpartDemo.wsp.&lt;br&gt;13. Open a command prompt, and type the following command:&lt;br&gt;stsadm -o addsolution -filename WebpartDemo.wsp&lt;br&gt;&lt;br&gt;Now, the SharePoint solution is added to SharePoint. You can deploy it further using the stsadm tool, or deploy the solution via the user interface of the SharePoint 3.0 Central Administration tool. The next procedure explains how to deploy the solution using the SharePoint 3.0 Central Administration tool:&lt;br&gt;1. Open SharePoint 3.0 Central Administration.&lt;br&gt;2. Click Operations. This opens the Operations page.&lt;br&gt;3. In the Global Configuration section, choose Solution Management. This opens the Solution&lt;br&gt;Management page. This is shown in Figure.&lt;br&gt;&lt;br&gt;&lt;img src=&quot;/Articles/webpart_14.jpg&quot;&gt;&lt;br&gt;&lt;br&gt;Click the MyWebpartDemoCab.wsp link. This opens the Solution Properties page, which is shown in Figure below:&lt;br&gt;&lt;br&gt;&lt;img src=&quot;/Articles/webpart_15.jpg&quot;&gt;&lt;br&gt;&lt;br&gt;5. Click Deploy Solution. This opens the Deploy Solution page, as shown in..&lt;br&gt;&lt;br&gt;&lt;img src=&quot;/Articles/webpart_16.jpg&quot;&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;6. In the Deploy to ? section, choose a Web application to deploy this solution.&lt;br&gt;7. Click OK. This opens the Solution Management page that is shown in Figure down below:&lt;br&gt;&lt;br&gt;&lt;img src=&quot;/Articles/webpart_17.jpg&quot;&gt;.&lt;br&gt;&lt;br&gt;At this point, the SharePoint solution is deployed to a specific SharePoint server and a specific SharePoint web application. Before you are able to use the web parts deployed using a SharePoint solution, you need to add them to the web part gallery of the site collection:&lt;br&gt;&lt;br&gt;8. Browse to the web application you have chosen in the previous step.&lt;br&gt;9. Choose Site Actions Site Settings. This opens the Site Settings page.&lt;br&gt;10. In the Galleries section, click Web Parts. This opens the Web Part Gallery page.&lt;br&gt;11. Click New. The web parts in the MyWebPartDemo assembly should be listed; select them&lt;br&gt;and click the Populate Gallery button.&lt;br&gt;You have seen how to create a SharePoint solution (.wsp) file that can be used to deploy web parts. After completing all the steps described in this section, you are ready to start using the web parts deployed via the SharePoint solution.&lt;br&gt;&lt;br&gt;Hope this helps a lot!..&lt;br&gt;</description>
    
    <category domain="http://www.purushotam.com/blog">Main Page</category>
    
    <category domain="http://www.purushotam.com/blog/SharePoint">SharePoint</category>
    
    
    <ent:cloud ent:href="">
    
    <ent:topic ent:id="deploy" ent:href="http://www.purushotam.com/blog/cmd=search_keyword/k=deploy">deploy</ent:topic>
    
    <ent:topic ent:id="solution" ent:href="http://www.purushotam.com/blog/cmd=search_keyword/k=solution">solution</ent:topic>
    
    <ent:topic ent:id="package" ent:href="http://www.purushotam.com/blog/cmd=search_keyword/k=package">package</ent:topic>
    
    <ent:topic ent:id="webpart" ent:href="http://www.purushotam.com/blog/cmd=search_keyword/k=webpart">webpart</ent:topic>
    
    </ent:cloud>
    
    
    
  </item>
  
  <item>
    <dc:creator>purushotam</dc:creator>
    <title>How to develop editor for a webpart in Sharepoint 2007</title>
    <link>http://www.purushotam.com/blog/_archives/2008/5/18/3826886.html</link>
    <guid>http://www.purushotam.com/blog/_archives/2008/5/18/3826886.html</guid>
    <pubDate>Sun, 18 May 2008 19:29:00 +0100</pubDate>
    <description>In my previous postings on webparts, i have demonstrated how to do it from scratch. In this article, i will explain how to incorporate editor for a webpart. If you have sufficient permissions, you are allowed to configure web parts. When you start configuring web parts via the user interface, a web part tool pane opens. Any configuration information&amp;nbsp; stored in the pane is persisted in the SharePoint content database. In my previous posting, you learned how to create properties that can be configured using the web part tool pane. The figure below shows an example of a web part tool pane.&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;img src=&quot;/Articles/webpart_9.jpg&quot;&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Out of the box, SharePoint offers different editors for different types of data. For instance, a string property is represented by the text box editor, while a Boolean property is represented by check boxes. In this section, you will learn how to create custom editor parts, which will be shown in the web part tool pane when you are configuring a web part.&lt;br&gt;&lt;br&gt;All editor parts inherit from the EditorPart base class, so that is the first step you need to take when creating a custom editor part. Editor parts look a lot like normal web parts. For instance, if you want to add child controls to an editor part, you need to override its CreateChildControls() method. The following code fragment adds a text area consisting of five lines to an editor part:&lt;br&gt;&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;protected override void CreateChildControls()&lt;br&gt;{&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;_txtNormalBox = new TextBox();&lt;br&gt;_txtNormalBox.ID = “txtNormalBox”;&lt;br&gt;_txtNormalBox.Text = “[Custom editor part]”;&lt;br&gt;_txtNormalBox.TextMode = TextBoxMode.MultiLine;&lt;br&gt;_txtNormalBox.Rows = 5;&lt;br&gt;Controls.Add(_txtNormalBox);&lt;br&gt;&lt;/div&gt;}&lt;br&gt;&lt;br&gt;You will also need to override the ApplyChanges() method of an EditorPart instance. This&lt;br&gt;method is responsible for mapping values in the editor part to corresponding properties in the&lt;br&gt;associated web part. The following code fragment shows how the ApplyChanges() method sets a&lt;br&gt;property in an instance of the MyWebPart web part called NormalValue:&lt;br&gt;&lt;br&gt;public override bool ApplyChanges()&lt;br&gt;{&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;MyWebPart objMyWebPart&amp;nbsp;  = (MyWebPart)WebPartToEdit;&lt;br&gt;objMyWebPart.NormalValue = _txtNormalBox.Text;&lt;br&gt;return true;&lt;br&gt;&lt;/div&gt;}&lt;br&gt;&lt;br&gt;&lt;/div&gt;The final piece of an editor part that must be implemented is the SyncChanges() method. This method is the opposite of the ApplyChanges() method; it retrieves property values from a web part and stores them in the editor part. The following code fragment shows an implementation for the SyncChanges() method that retrieves the NormalValue property of a MyWebPart web part and stores it in the text area of the web part editor tool pane:&lt;br&gt;&lt;br&gt;public override void SyncChanges()&lt;br&gt;{&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;// Make sure the text area child control is created.&lt;br&gt;EnsureChildControls();&lt;br&gt;MyWebPart objMyWebPart  = (MyWebPart ) WebPartToEdit;&lt;br&gt;_txtNormalBox.Text = objMyWebPart.NormalValue;&lt;br&gt;&lt;/div&gt;}&lt;br&gt;&lt;br&gt;So far, you have seen how to create an editor part. Before a custom editor part is shown in the web part editor tool pane, you need to implement support for this in your web part. In this example, we are creating a web part called MyWebPart. First, we need to add one or more properties that are read from and written to within the editor part. The custom editor part in this section expects the&lt;br&gt;presence of a NormalValue property in a web part, so that is the first thing that needs to be implemented.&lt;br&gt;&lt;br&gt;The following code snippet shows how to implement the NormalValue property:&lt;br&gt;&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;private string _strNormalValue = String.Empty;&lt;br&gt;[Personalizable(PersonalizationScope.Shared), WebBrowsable(false), WebDisplayName(“Normal value”), WebDescription(“Normal value description”)]&lt;br&gt;public string NormalValue&lt;br&gt;{&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;get { return _strNormalValue; }&lt;br&gt;set { _strNormalValue = value; }&lt;br&gt;&lt;/div&gt;}&lt;br&gt;&lt;br&gt;&lt;/div&gt;After that, you need to override the CreateEditorParts() method. This method is responsible for returning a collection of custom editor part controls that are shown in the web part editor tool pane when a web part is in edit mode. Basically, this method is used to create a new instance of one or more custom editor parts and add those to the editor part collection. This collection is used&lt;br&gt;when the web part tool pane is rendered. The following code fragment shows how to add the MyWebPartEditorPart editor part to the collection of customer editor parts that is shown when the MyWebPart web part is being edited:&lt;br&gt;&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;public override EditorPartCollection CreateEditorParts()&lt;br&gt;{&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;MyWebPartEditorPart objEditor = new MyWebPartEditorPart ();&lt;br&gt;objEditor.ID = ID + “normalEditor1”;&lt;br&gt;objEditor.Title = “Normal Editor title”;&lt;br&gt;objEditor.ToolTip = “Normal Editor tooltip”;&lt;br&gt;objEditor.TabIndex = 100;&lt;br&gt;objEditor.GroupingText = “Normal editor grouping text”;&lt;br&gt;ArrayList objEditorParts = new ArrayList();&lt;br&gt;objEditorParts.Add(objEditor);&lt;br&gt;EditorPartCollection objEditorPartsCollection = new&lt;br&gt;EditorPartCollection(objEditorParts);&lt;br&gt;return objEditorPartsCollection;&lt;br&gt;&lt;/div&gt;}&lt;br&gt;&lt;br&gt;&lt;/div&gt;and here is the complete code:&lt;br&gt;&lt;br&gt;using System;&lt;br&gt;using System.Runtime.InteropServices;&lt;br&gt;using System.Web.UI;&lt;br&gt;using System.Web.UI.WebControls;&lt;br&gt;using System.Web.UI.WebControls.WebParts;&lt;br&gt;using System.Xml.Serialization;&lt;br&gt;namespace KwikSliver.Sharepoint.WebpartDemo&lt;br&gt;{&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;public class MyWebPartEditorPart : EditorPart&lt;br&gt;{&lt;br&gt;TextBox _txtNormalBox;&lt;br&gt;protected override void CreateChildControls()&lt;br&gt;{&lt;br&gt;_txtNormalBox = new TextBox();&lt;br&gt;_txtNormalBox.ID = “txtNormalBox”;&lt;br&gt;_txtNormalBox.Text = “[Custom editor part]”;&lt;br&gt;_txtNormalBox.TextMode = TextBoxMode.MultiLine;&lt;br&gt;_txtNormalBox.Rows = 5;&lt;br&gt;Controls.Add(_txtNormalBox);&lt;br&gt;}&lt;br&gt;public override bool ApplyChanges()&lt;br&gt;{&lt;br&gt;MyWebPart objMyWebPart  = (MyWebPart )WebPartToEdit;&lt;br&gt;objMyWebPart.NormalValue = _txtNormalBox.Text;&lt;br&gt;return true;&lt;br&gt;}&lt;br&gt;public override void SyncChanges()&lt;br&gt;{&lt;br&gt;EnsureChildControls();&lt;br&gt;MyWebPart objMyWebPart  = (MyWebPart)WebPartToEdit;&lt;br&gt;_txtNormalBox.Text = objMyWebPart  .NormalValue;&lt;br&gt;}&lt;br&gt;}&lt;br&gt;&lt;/div&gt;}&lt;br&gt;&lt;br&gt;and below shown is the code for implementation of the MyWebPart web part. This web part displays the custom MyWebPartEditorPart web part in edit mode:&lt;br&gt;&lt;br&gt;using System;&lt;br&gt;using System.Collections;&lt;br&gt;using System.Runtime.InteropServices;&lt;br&gt;using System.Web.UI;&lt;br&gt;using System.Web.UI.WebControls;&lt;br&gt;using System.Web.UI.WebControls.WebParts;&lt;br&gt;using System.Xml.Serialization;&lt;br&gt;using System;&lt;br&gt;using System.Collections;&lt;br&gt;using System.Runtime.InteropServices;&lt;br&gt;using System.Web.UI;&lt;br&gt;using System.Web.UI.WebControls;&lt;br&gt;using System.Web.UI.WebControls.WebParts;&lt;br&gt;using System.Xml.Serialization;&lt;br&gt;using Microsoft.SharePoint;&lt;br&gt;using Microsoft.SharePoint.WebControls;&lt;br&gt;using Microsoft.SharePoint.WebPartPages;&lt;br&gt;using Microsoft.SharePoint.Administration;&lt;br&gt;using Microsoft.SharePoint.Utilities;&lt;br&gt;namespace KwikSilver.Sharepoint.WebpartDemo&lt;br&gt;{&lt;br&gt;[Guid(“288802c4-4dfe-45b6-bb28-49dda89ec225”)]&lt;br&gt;public class MyWeblPart : System.Web.UI.WebControls.WebParts.WebPart&lt;br&gt;{&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;protected override void RenderContents(HtmlTextWriter writer)&lt;br&gt;{&lt;br&gt;writer.Write(“Normalvalue: “ + NormalValue);&lt;br&gt;}&lt;br&gt;public override EditorPartCollection CreateEditorParts()&lt;br&gt;{&lt;br&gt;MyWeblPartEditorPart objEditor = new MyWeblPartEditorPart ();&lt;br&gt;objEditor.ID = ID + “normalEditor1”;&lt;br&gt;objEditor.Title = “Normal Editor title”;&lt;br&gt;objEditor.ToolTip = “Normal Editor tooltip”;&lt;br&gt;objEditor.TabIndex = 100;&lt;br&gt;objEditor.GroupingText = “Normal editor grouping text”;&lt;br&gt;ArrayList objEditorParts = new ArrayList();&lt;br&gt;objEditorParts.Add(objEditor);&lt;br&gt;EditorPartCollection objEditorPartsCollection = new EditorPartCollection(objEditorParts);&lt;br&gt;return objEditorPartsCollection;&lt;br&gt;}&lt;br&gt;private string _strNormalValue = String.Empty;&lt;br&gt;[Personalizable(PersonalizationScope.Shared), WebBrowsable(false), WebDisplayName(“Normal value”), WebDescription(“Normal value description”)]&lt;br&gt;public string NormalValue&lt;br&gt;{&lt;br&gt;get { return _strNormalValue; }&lt;br&gt;set { _strNormalValue = value; }&lt;br&gt;}&lt;br&gt;&lt;/div&gt;&amp;nbsp;}&lt;br&gt;}&lt;br&gt;&lt;br&gt;and here is the end result for all the efforts made above!..&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;img src=&quot;/Articles/webpart_10.jpg&quot;&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;&lt;br&gt;&lt;br&gt;&lt;/div&gt;&lt;br&gt;</description>
    
    <category domain="http://www.purushotam.com/blog">Main Page</category>
    
    <category domain="http://www.purushotam.com/blog/SharePoint">SharePoint</category>
    
    
    
    
  </item>
  
  <item>
    <dc:creator>purushotam</dc:creator>
    <title>How to develop menu for a Webpart in Sharepoint 2007</title>
    <link>http://www.purushotam.com/blog/_archives/2008/5/14/3826852.html</link>
    <guid>http://www.purushotam.com/blog/_archives/2008/5/14/3826852.html</guid>
    <pubDate>Wed, 14 May 2008 13:07:00 +0100</pubDate>
    <description>In this posting i will demonstrate how to create menu for a webpart in Sharepoint 2007.&lt;br&gt;&lt;br&gt;Every web part on a SharePoint page has a web part menu that contains standard options such as the ability to minimize or close the web part. An example of a standard web part menu is shown in figure down below:&lt;br&gt;&lt;br&gt;In this section, you will learn how to create custom web part menu verbs that are added to the verbs menu in a web part’s header. To start with, it is good to realize that there are three kinds of web part menu verbs:&lt;br&gt;&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;• Client-side verbs. These verbs perform some kind of action on the client side.&lt;br&gt;• Server-side verbs. These verbs perform some kind of action on the server side.&lt;br&gt;• Both. These verbs perform actions on both the client and server side.&lt;br&gt;&lt;br&gt;&lt;/div&gt;You can create a client-side verb by creating a new instance of the WebPartVerb class. The first argument that needs to be passed to the WebPartVerb constructor for a client-side verb is the verb’s id. This needs to be unique. The second argument refers to the client-click event handler. This typically refers to a piece of JavaScript that needs to be executed once an end user clicks on a web part menu verb. The following code fragment shows how to create a client-side verb:&lt;br&gt;&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;WebPartVerb objFirst = new WebPartVerb(“FirstVerbId”, “javascript:alert(‘Hello from verb!’);”);&lt;br&gt;objFirst.Text = “first verb text”;&lt;br&gt;objFirst.Description = “first verb description”;&lt;br&gt;objFirst.ImageUrl = “_layouts/images/kwiksilver/favicon.gif”;&lt;br&gt;&lt;br&gt;&lt;/div&gt;If you want to create a server-side verb, you need to instantiate a new WebPartVerb class, pass it a unique verb id, and specify a server-side event handler to be executed once an end user clicks on the verb. The next code fragment shows how to create a server-side verb:&lt;br&gt;&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;WebPartVerb objSecond = new WebPartVerb(“SecondVerbId”,new WebPartEventHandler(SecondVerbHandler));&lt;br&gt;objSecond.Text = “second verb text”;&lt;br&gt;objSecond.Description = “second verb description”;&lt;br&gt;&lt;br&gt;&lt;/div&gt;The final web part menu verb type, the kind that performs both client-side and server-side actions, is created by passing a unique verb id, a server-side event handler, and a client-side event handler. You can add custom web part verbs by overriding the Verbs property of a web part and adding custom verbs to it. The code listing shows how to add custom verbs to the web part menu and define an event handler that handles a server-side verb click event:&lt;br&gt;&lt;br&gt;using System;&lt;br&gt;using System.Runtime.InteropServices;&lt;br&gt;using System.Web.UI;&lt;br&gt;using System.Web.UI.WebControls;&lt;br&gt;using System.Web.UI.WebControls.WebParts;&lt;br&gt;using System.Xml.Serialization;&lt;br&gt;using Microsoft.SharePoint;&lt;br&gt;using Microsoft.SharePoint.WebControls;&lt;br&gt;using Microsoft.SharePoint.WebPartPages;&lt;br&gt;using Microsoft.SharePoint.Administration;&lt;br&gt;using Microsoft.SharePoint.Utilities;&lt;br&gt;using System.Net;&lt;br&gt;using System.Net.Mail;&lt;br&gt;namespace KwikSilver.Sharepoint.WebpartDemo&lt;br&gt;{&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;[Guid(“288802c4-4dfe-45b6-bb28-49dda89ec225”)]&lt;br&gt;public class MyMenuWebPart : System.Web.UI.WebControls.WebParts.WebPart&lt;br&gt;{&lt;br&gt;public override WebPartVerbCollection Verbs&lt;br&gt;{&lt;br&gt;get&lt;br&gt;{&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;WebPartVerb objFirst = new WebPartVerb(“FirstVerbId”, “javascript:alert(‘Hello from verb!’);”);&lt;br&gt;objFirst.Text = “first verb text”;&lt;br&gt;objFirst.Description = “first verb description”;&lt;br&gt;objFirst.ImageUrl = “_layouts/images/kwiksilver/favicon.gif”;&lt;br&gt;WebPartVerb objSecond = new WebPartVerb(“SecondVerbId”, new WebPartEventHandler(SecondVerbHandler));&lt;br&gt;objSecond.Text = “second verb text”;&lt;br&gt;objSecond.Description = “second verb description”;&lt;br&gt;WebPartVerb[] objVerbs = new WebPartVerb[] {objFirst, objSecond};&lt;br&gt;WebPartVerbCollection objVerbCollection = new WebPartVerbCollection(base.Verbs, objVerbs);&lt;br&gt;return objVerbCollection;&lt;br&gt;}&lt;br&gt;&lt;/div&gt;}&lt;br&gt;protected void SecondVerbHandler(object sender, WebPartEventArgs args)&lt;br&gt;{&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;//Do something...&lt;br&gt;&lt;/div&gt;}&lt;br&gt;}&lt;br&gt;&lt;/div&gt;}&lt;br&gt;&lt;br&gt;This code adds two web part verbs to the web part menu: a client-side verb and a server-side verb. Both verbs are shown in Figure.&lt;br&gt;&lt;br&gt;&lt;img src=&quot;/Articles/webpart_7.jpg&quot;&gt;&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;&lt;br&gt;and Figure down below shows what happens when you click on the client-side verb. Some JavaScript will&lt;br&gt;be executed that displays an alert box.&lt;br&gt;&lt;br&gt;&lt;img src=&quot;/Articles/webpart_8.jpg&quot;&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;In this posting, you have seen that adding verbs to a web part menu enhances the user interface experience and is quite easy to accomplish.&lt;br&gt;&lt;br&gt;In my next posting, you will find how to create webpart with custom editor in it.&lt;br&gt;&lt;br&gt;&lt;/div&gt;</description>
    
    <category domain="http://www.purushotam.com/blog">Main Page</category>
    
    <category domain="http://www.purushotam.com/blog/SharePoint">SharePoint</category>
    
    
    <ent:cloud ent:href="">
    
    <ent:topic ent:id="menu" ent:href="http://www.purushotam.com/blog/cmd=search_keyword/k=menu">menu</ent:topic>
    
    <ent:topic ent:id="webpart" ent:href="http://www.purushotam.com/blog/cmd=search_keyword/k=webpart">webpart</ent:topic>
    
    </ent:cloud>
    
    
    
  </item>
  
  <item>
    <dc:creator>purushotam</dc:creator>
    <title>How to develop Configurable Webpart for Sharepoint 2007</title>
    <link>http://www.purushotam.com/blog/_archives/2008/5/7/3826803.html</link>
    <guid>http://www.purushotam.com/blog/_archives/2008/5/7/3826803.html</guid>
    <pubDate>Wed, 07 May 2008 23:51:00 +0100</pubDate>
    <description>In this posting, i would concentrate on developing a web part which could have configuration settings. &lt;br&gt;&lt;br&gt;If you are building a generic web part, you probably will need to be able to configure it on a per-web&lt;br&gt;part basis. You can use web part properties and the Web Part Editor tool pane to configure web&lt;br&gt;parts, as you will see in this section. Such configuration information is stored in the SharePoint content&lt;br&gt;database.&lt;br&gt;&lt;br&gt;To demonstrate web part configuration via properties, we will create a web part that uploads a&lt;br&gt;local file to a SharePoint document library. File upload in ASP.NET 1.x was possible, although you&lt;br&gt;did have to jump through some hoops to get everything working. For example, you had to add&lt;br&gt;enctype=”multipart/form-data” to the page’s &amp;lt;form&amp;gt; element. The new ASP.NET 2.0 FileUpload&lt;br&gt;server control makes the process of uploading files to the hosting server as simple as possible.&lt;br&gt;The FileUpload control displays a text box and a Browse button that allow users to select a file&lt;br&gt;to upload to the server. The user specifies the file to upload by entering the fully qualified path to&lt;br&gt;the file on the local computer (for example, C:\Temp\Test.txt) in the text box of the control. The&lt;br&gt;user can also select the file by clicking the Browse button and then locating it in the Choose File dialog&lt;br&gt;box. You need to hook up an event handler to a Submit button, which calls the SaveAs() method&lt;br&gt;of the FileUpLoad control. Via this method, you can specify the location where the file will be saved.&lt;br&gt;The file will not be uploaded to the server until the user clicks the Submit button.&lt;br&gt;To build this web part, we need three configurable properties to store the following information:&lt;br&gt;&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;• Site collection URL&lt;br&gt;• Site URL&lt;br&gt;• Name of the document library that is going to hold the uploaded file&lt;br&gt;&lt;/div&gt;&lt;br&gt;If you want to create a configurable property, you first need to add the [Personalizable]&lt;br&gt;attribute to a property to indicate that the property supports personalization. You also need to specify&lt;br&gt;the personalization scope that associates the scope of a web part property to the state a web part&lt;br&gt;page is running in. This determines which configuration data is retrieved from the SharePoint configuration&lt;br&gt;database. You can set the personalization scope to either Shared or User.&lt;br&gt;Setting the personalization scope of a web part to Shared ensures that the data associated with&lt;br&gt;a page running in Shared mode is retrieved. In this case, the configuration information applies to all&lt;br&gt;users viewing the web part.&lt;br&gt;&lt;br&gt;You can also set the personalization scope of a web part to User to make sure that the data&lt;br&gt;associated to a page running in User mode is retrieved. Such configuration information indicates&lt;br&gt;that configuration information is retrieved for the currently executing user.&lt;br&gt;&lt;br&gt;In this example, we are not interested in user-specific data; we are interested in application specific&lt;br&gt;data. As a result, we will set the personalization scope to Shared. You will also need to set&lt;br&gt;the [WebBrowsable] attribute to true to make it appear in the web part tool pane. In addition, you&lt;br&gt;can use the [WebDisplayName] and [WebDescription] attributes to define a friendly name and&lt;br&gt;description for the web part property. This information is shown in the web part tool pane. The following&lt;br&gt;code fragment shows a web part property containing the URL of a site collection that is&lt;br&gt;personalizable, stores configuration on an application-wide basis, and defines a friendly name and&lt;br&gt;description:&lt;br&gt;&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;private string _strSiteCollectionUrl;&lt;br&gt;[Personalizable(PersonalizationScope.Shared),&lt;br&gt;WebBrowsable(true),&lt;br&gt;WebDisplayName(“Site Collection URL”),&lt;br&gt;WebDescription(“Enter the URL of the site collection that contains the&lt;br&gt;list a document is uploaded to”)]&lt;br&gt;public string SiteCollectionUrl&lt;br&gt;{&lt;br&gt;get { return _strSiteCollectionUrl; }&lt;br&gt;set { _strSiteCollectionUrl = value; }&lt;br&gt;}&lt;br&gt;&lt;br&gt;&lt;/div&gt;The web part in this section opens a site collection containing the document library that will&lt;br&gt;hold the uploaded file. Then, it opens the site that contains this document library, and finally, it&lt;br&gt;opens the document library itself. In this example, we are saving uploaded files to the root folder of&lt;br&gt;the document library by using the Add() method of the RootFolder object’s Files collection. By passing&lt;br&gt;the input stream of the FileUpload control to the Add() method, you can save a file to a&lt;br&gt;document library. The next code fragment shows how to save a file uploaded via the FileUpload&lt;br&gt;control in a document library, overwriting files that have the same name:&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;&lt;br&gt;using (SPSite objSite = new SPSite(SiteCollectionUrl))&lt;br&gt;{&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;using (SPWeb objWeb = objSite.OpenWeb(SiteUrl))&lt;br&gt;{&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;SPList objList = objWeb.Lists[ListName];&lt;br&gt;if (_objFileUpload.HasFile)&lt;br&gt;{&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;objList.RootFolder.Files.Add(_objFileUpload.FileName, å&lt;br&gt;_objFileUpload.PostedFile.InputStream, true);&lt;br&gt;&lt;/div&gt;}&lt;br&gt;&lt;/div&gt;}&lt;br&gt;&lt;/div&gt;}&lt;br&gt;&lt;br&gt;&lt;/div&gt;The complete code for a configurable web part that uses the FileUpload control to upload a file&lt;br&gt;to a SharePoint document library is shown down below:&lt;br&gt;&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;using System;&lt;br&gt;using System.Runtime.InteropServices;&lt;br&gt;using System.Web.UI;&lt;br&gt;using System.Web.UI.WebControls;&lt;br&gt;using System.Web.UI.WebControls.WebParts;&lt;br&gt;using System.Xml.Serialization;&lt;br&gt;using Microsoft.SharePoint;&lt;br&gt;using Microsoft.SharePoint.WebControls;&lt;br&gt;using Microsoft.SharePoint.WebPartPages;&lt;br&gt;&lt;br&gt;namespace KwikSilver.Sharepoint.WebpartDemo&lt;br&gt;{&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;[Guid(“288802c4-4dfe-45b6-bb28-49dda89ec225”)]&lt;br&gt;public class MyFileUploadlPart : System.Web.UI.WebControls.WebParts.WebPart&lt;br&gt;{&lt;br&gt;FileUpload _objFileUpload = new FileUpload();&lt;br&gt;protected override void CreateChildControls()&lt;br&gt;{&lt;br&gt;Controls.Add(_objFileUpload);&lt;br&gt;Button btnUpload = new Button();&lt;br&gt;btnUpload.Text = “Save File”;&lt;br&gt;this.Load += new System.EventHandler(btnUpload_Click);&lt;br&gt;Controls.Add(btnUpload);&lt;br&gt;}&lt;br&gt;private void btnUpload_Click(object sender, EventArgs e)&lt;br&gt;{&lt;br&gt;using (SPSite objSite = new SPSite(SiteCollectionUrl))&lt;br&gt;{&lt;br&gt;using (SPWeb objWeb = objSite.OpenWeb(SiteUrl))&lt;br&gt;{&lt;br&gt;SPList objList = objWeb.Lists[ListName];&lt;br&gt;if (_objFileUpload.HasFile)&lt;br&gt;{&lt;br&gt;objList.RootFolder.Files.Add(_objFileUpload.FileName,&lt;br&gt;_objFileUpload.PostedFile.InputStream, true);&lt;br&gt;}&lt;br&gt;}&lt;br&gt;}&lt;br&gt;}&lt;br&gt;private string _strSiteCollectionUrl;&lt;br&gt;[Personalizable(PersonalizationScope.Shared), WebBrowsable(true),&lt;br&gt;WebDisplayName(“Site Collection URL”),&lt;br&gt;WebDescription(“Enter the URL of the site collection that contains&lt;br&gt;the list a document is uploaded to”)]&lt;br&gt;public string SiteCollectionUrl&lt;br&gt;{&lt;br&gt;get { return _strSiteCollectionUrl; }&lt;br&gt;set { _strSiteCollectionUrl = value; }&lt;br&gt;}&lt;br&gt;private string _strSiteUrl;&lt;br&gt;[Personalizable(PersonalizationScope.Shared),&lt;br&gt;WebBrowsable(true), WebDisplayName(“Site Collection URL”),&lt;br&gt;WebDescription(“Enter the URL of the site that contains&lt;br&gt;the list a document is uploaded to”)]&lt;br&gt;public string SiteUrl&lt;br&gt;{&lt;br&gt;get { return _strSiteUrl; }&lt;br&gt;set { _strSiteUrl = value; }&lt;br&gt;}&lt;br&gt;private string _strListName;&lt;br&gt;[Personalizable(PersonalizationScope.Shared),WebBrowsable(true),WebDisplayName(“List name”), WebDescription(“Enter the name of the list that will contain the uploaded document”)]&lt;br&gt;public string ListName&lt;br&gt;{&lt;br&gt;get { return _strListName; }&lt;br&gt;set { _strListName = value; }&lt;br&gt;}&lt;br&gt;}&lt;br&gt;&lt;/div&gt;}&lt;br&gt;&lt;br&gt;&lt;/div&gt;The following figure shows the FileUpload web part (called MyFileUploadPart) in action. First, the web part&lt;br&gt;allows you to choose a local file (test.txt) that you want to upload to a SharePoint document library.&lt;br&gt;&lt;br&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;/Articles/webpart_4.jpg&quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;br&gt;and the local file test.txt is uploaded to a document library called Shared Documents as in fig below:&lt;br&gt;&lt;br&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;/Articles/webpart_5.jpg&quot;&gt;&lt;br&gt;&lt;br&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;/div&gt;&lt;br&gt;</description>
    
    <category domain="http://www.purushotam.com/blog">Main Page</category>
    
    <category domain="http://www.purushotam.com/blog/SharePoint">SharePoint</category>
    
    
    
    
  </item>
  
  <item>
    <dc:creator>purushotam</dc:creator>
    <title>Creating Web Part for Sharepoint</title>
    <link>http://www.purushotam.com/blog/_archives/2008/5/5/3826765.html</link>
    <guid>http://www.purushotam.com/blog/_archives/2008/5/5/3826765.html</guid>
    <pubDate>Mon, 05 May 2008 21:16:00 +0100</pubDate>
    <description>In this article, I will demonstrate how to create a simple web part.&lt;br&gt;&lt;div style=&quot;text-align: left;&quot;&gt;If you have installed VSeWSS (make sure you have installed Visual Studio 2005 Extensions, if not you can download from: http://www.microsoft.com/downloads/details.aspx?familyid=19f21e5e-b715-4f0c-b959-8c6dcbdc1057&amp;amp;displaylang=en) &lt;br&gt;and then start Visual Studio 2005, you will find that a new set of Visual Studio project templates is available when you create &lt;br&gt;a new project. &lt;br&gt;&amp;nbsp; The new project templates are available in the Visual C# SharePoint section, as shown in Figure down below:&lt;br&gt;&lt;br&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;file:///C:/Users/PURUSH%7E1/AppData/Local/Temp/moz-screenshot-1.jpg&quot; alt=&quot;&quot;&gt;&lt;img src=&quot;/Articles/webpart_1.jpg&quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;/div&gt;&lt;img src=&quot;file:///C:/Users/PURUSH%7E1/AppData/Local/Temp/moz-screenshot.jpg&quot; alt=&quot;&quot;&gt;&lt;br&gt;The following project templates are added by Visual Studio 2005 extensions for Windows SharePoint Services 3.0:&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;• Team Site Definition&lt;br&gt;• List Definition&lt;br&gt;• Empty&lt;br&gt;• Blank Site Definition&lt;br&gt;• Web Part&lt;br&gt;&lt;/div&gt;&lt;br&gt;Visual Studio 2005 extensions for Windows SharePoint Services 3.0 also contains a set of item templates that can be used &lt;br&gt;within SharePoint projects for Visual Studio 2005. The following item templates are added by VSeWSS:&lt;br&gt;&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;• List Definition&lt;br&gt;• Content Type&lt;br&gt;• Web Part&lt;br&gt;• List Definition from Content Type&lt;br&gt;• Field Control&lt;br&gt;• Module&lt;br&gt;&lt;/div&gt;&lt;br&gt;The item templates for Visual Studio are found in the Visual C# Project Items SharePoint section of the Add New Item – [name of project] window. This is shown in Figure down below:&lt;br&gt;&lt;br&gt;&lt;img src=&quot;/Articles/webpart_2.jpg&quot;&gt;&lt;br&gt;&lt;br&gt;In the next procedure, we will add a new web part and have it write a “Hello!” message to the page that contains the web part.&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;1. Right-click the WPLibrary folder in the Solution Explorer, and choose Add New Item. This opens the Add New Item - [name of project] window.&lt;br&gt;2. Under Visual C# Project Items SharePoint, select the Web Part item template.&lt;br&gt;3. In the Name text field, enter the following name: MyWebPart.&lt;br&gt;4. Click Add. This adds a new MyWebPart folder that includes a class called MyWebPart.cs.&lt;br&gt;5. Open MyWebPart.cs. This is an ASP.NET 2.0 web part.&lt;br&gt;6. Add the following code to the body of the MyWebPart.cs class:&lt;br&gt;&lt;/div&gt;&lt;br&gt;&lt;div style=&quot;text-align: left; margin-left: 40px;&quot;&gt;protected override void RenderContents(HtmlTextWriter writer)&lt;br&gt;{&lt;br&gt;writer.Write(“Hello!”);&lt;br&gt;}&lt;br&gt;&lt;/div&gt;&lt;br&gt;One of the nice features of the Web Part project template is the ability to package a web part within the project as a SharePoint feature. Features make it easy to deploy and activate web parts (and they can do a lot more than that).&lt;br&gt;You have fine-grained influence over the settings of a web part feature. &lt;br&gt;&lt;br&gt;The following procedure explains how to configure feature settings:&lt;br&gt;&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;1. Right-click the WPLibrary project and choose Properties.&lt;br&gt;2. Click the SharePoint solution tab.&lt;br&gt;&lt;/div&gt;&lt;br&gt;At this point, you are almost ready to deploy the web parts in your web part solution. &lt;br&gt;First, you must configure to which SharePoint site the web part solution needs to be deployed. This is explained in the next procedure:&lt;br&gt;&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;1. Right-click WPLibrary and choose Properties.&lt;br&gt;2. Click the Debug tab.&lt;br&gt;3. In the Start Action section, make sure the Start browser with URL radio button is selected.&lt;br&gt;4. Enter the SharePoint site URL into the Start browser with URL text field.&lt;br&gt;&lt;/div&gt;&lt;br&gt;Deploying a web part has never been easier; all you need to do is press F5 (or Debug Start Debugging).&lt;br&gt;&amp;nbsp;When you do this, a couple of things happen:&lt;br&gt;&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;1. The web part solution is compiled.&lt;br&gt;2. The web part solution is packaged as a feature.&lt;br&gt;3. If a previous version of the web part feature exists, it is removed.&lt;br&gt;4. The web part library is added to the Global Assembly Cache (GAC).&lt;br&gt;5. The web part feature is deployed to the SharePoint site URL you specified earlier.&lt;br&gt;6. If deployment is successful, the web part feature is activated.&lt;br&gt;7. The web parts in the web part library are added to the &amp;lt;SafeControls&amp;gt; list in the web.config file of the SharePoint web application that contains the web part.&lt;br&gt;8. The web part gallery is modified so that the site can use the web parts.&lt;br&gt;9. Internet Information Services (IIS) is restarted.&lt;br&gt;10. If debugging is enabled, Visual Studio 2005 automatically tries to attach to the w3wp process hosting the web part.&lt;br&gt;&lt;/div&gt;&lt;br&gt;Now, you should go ahead and add the web part to a web part page. The following procedure explains how to do this:&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;1. Navigate to the SharePoint site URL you specified earlier.&lt;br&gt;2. Choose Site Actions Edit Page. This opens the page in Edit Mode.&lt;br&gt;3. Choose a web part zone and click the Add a Web Part link. This opens the Add Web Parts Web Page Dialog window.&lt;br&gt;4. Locate the All Web Parts äMiscellaneous section and select the MyWebPart Web Part checkbox.&lt;br&gt;5. Click the Add button.&lt;br&gt;&lt;/div&gt;&lt;br&gt;This adds the MyWebPart web part to the page. If you want to go ahead and debug this web part, follow these steps:&lt;br&gt;&lt;div style=&quot;margin-left: 40px;&quot;&gt;1. Open a command prompt and type inetmgr. This opens Internet Information Services (IIS) Manager.&lt;br&gt;2. Expand the [computer name] (local computer) node.&lt;br&gt;3. Expand the Web Sites node.&lt;br&gt;4. Locate the SharePoint web site that contains your web part, right-click it, and choose Properties. This opens the [web site name] Properties window.&lt;br&gt;5. Click the Home Directory tab.&lt;br&gt;6. Copy the value of the Local Path text field.&lt;br&gt;7. Open Windows Explorer and navigate to the local path you copied in the previous step. This opens the root folder of the SharePoint web application that contains your web part. &lt;br&gt;8. Set a break point to a line of code in the web part. &lt;br&gt;9. Press F5.&lt;br&gt;&lt;/div&gt;&lt;br&gt;After deployment, Visual Studio 2005 attaches automatically to the process hosting your web part, and break mode is entered automatically. This is shown in Figure down below:&lt;br&gt;&lt;br&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;img src=&quot;/Articles/webpart_3.jpg&quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;br&gt;and.. That&#39;s it. You now have created simple webpart. In next posting i will discuss how to develop a configurable webpart.&lt;br&gt;</description>
    
    <category domain="http://www.purushotam.com/blog">Main Page</category>
    
    <category domain="http://www.purushotam.com/blog/SharePoint">SharePoint</category>
    
    
    <ent:cloud ent:href="">
    
    <ent:topic ent:id="webpart" ent:href="http://www.purushotam.com/blog/cmd=search_keyword/k=webpart">webpart</ent:topic>
    
    </ent:cloud>
    
    
    
  </item>
  
  <item>
    <dc:creator>purushotam</dc:creator>
    <title>WCF Hello World Part -2</title>
    <link>http://www.purushotam.com/blog/_archives/2008/4/8/3744848.html</link>
    <guid>http://www.purushotam.com/blog/_archives/2008/4/8/3744848.html</guid>
    <pubDate>Tue, 08 Apr 2008 21:46:00 +0100</pubDate>
    <description>In my &lt;a href=&quot;http://www.purushotam.com/blog/_archives/2008/4/3/3744841.html&quot;&gt;previous&lt;/a&gt; post, I have created a WCF service. In this part, I will create a
client to consume the WCF Service created. Since this is an hello world
example, Let&#39;s create a web method in WCF service. Todo that, create a
method first on interface and then implement it in the service as shown
in code.

&lt;div&gt;&lt;pre style=&quot;border: 1px solid rgb(218, 218, 218); padding: 5px; overflow: scroll; font-family: &#39;Courier New&#39;,Monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 100%; line-height: normal; font-size-adjust: none; font-stretch: normal; width: 95%; height: 300px; color: rgb(102, 153, 51); background-color: rgb(240, 240, 240);&quot;&gt;[ServiceContract]&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public interface IHelloWorldService&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [OperationContract]&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string GetData(int value);&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [OperationContract]&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CompositeType GetDataUsingDataContract(CompositeType composite);&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // TODO: Add your service operations here&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [OperationContract]&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string GetGreetings(string name);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&lt;br&gt;&amp;nbsp;public class HelloWorldService : IHelloWorldService&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string GetGreetings(string name)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return string.Format(&quot;Hello {0}, Welcome to WCF World!&quot;, name);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ....&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&lt;br&gt;&lt;/pre&gt;&lt;/div&gt;

Now, lets create a client to consume this service. I prefer to create a
web client. In order to do this, one needs a service proxy, which will
communicate to the service using Soap as transport mechanism. There are
2 ways to create a proxy.
1. by using Visual Studio
2. by using svcutil.exe utility by WCF framework.


for this example, i will simply use Visual Studio as we used to do
earlier versions of .net. Add a new website by name WCFHelloWorld-Web
and add a service reference and point to the WCF service created as
show shown fig below.

&lt;a href=&quot;http://bp1.blogger.com/_QsDuG4K936c/R_uGSXOn5oI/AAAAAAAAGMs/WVdjMzXxH4g/s1600-h/WCFHelloWorld-Part2_1.jpg&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;&quot; src=&quot;http://bp1.blogger.com/_QsDuG4K936c/R_uGSXOn5oI/AAAAAAAAGMs/WVdjMzXxH4g/s320/WCFHelloWorld-Part2_1.jpg&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5186887045878376066&quot; border=&quot;0&quot;&gt;&lt;/a&gt;


&lt;a href=&quot;http://bp3.blogger.com/_QsDuG4K936c/R_uHl3On5pI/AAAAAAAAGM0/kE4eEdwJpu0/s1600-h/WCFHelloWorld-Part2_2.jpg&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;&quot; src=&quot;http://bp3.blogger.com/_QsDuG4K936c/R_uHl3On5pI/AAAAAAAAGM0/kE4eEdwJpu0/s320/WCFHelloWorld-Part2_2.jpg&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5186888480397452946&quot; border=&quot;0&quot;&gt;&lt;/a&gt;


Add namespace of WCF Service to codebehind of aspx file, in this case
ServiceReference1 is the namespace. using this namespace, create a
proxy object as class variable in the aspx.cs file and in aspx file
create some server controls in order to type some input and display as
label. I have created UI as follows:

&lt;a href=&quot;http://bp3.blogger.com/_QsDuG4K936c/R_uJ_3On5qI/AAAAAAAAGM8/lvKL8fWc2nI/s1600-h/WCFHelloWorld-Part2_3.jpg&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;&quot; src=&quot;http://bp3.blogger.com/_QsDuG4K936c/R_uJ_3On5qI/AAAAAAAAGM8/lvKL8fWc2nI/s320/WCFHelloWorld-Part2_3.jpg&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5186891126097307298&quot; border=&quot;0&quot;&gt;&lt;/a&gt;

and in button event handler, pass the textbox input to webservice&#39;s&amp;nbsp;
GetGreetings method and display on UI with label as shown below:

&lt;div&gt;&lt;pre style=&quot;border: 1px solid rgb(218, 218, 218); padding: 5px; overflow: scroll; font-family: &#39;Courier New&#39;,Monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 100%; line-height: normal; font-size-adjust: none; font-stretch: normal; width: 95%; height: 300px; color: rgb(102, 153, 51); background-color: rgb(240, 240, 240);&quot;&gt;using ServiceReference1;&lt;br&gt;&lt;br&gt;public partial class _Default : System.Web.UI.Page &lt;br&gt;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; HelloWorldServiceClient proxy = new HelloWorldServiceClient();&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected void Page_Load(object sender, EventArgs e)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected void btnSumbit_Click(object sender, EventArgs e)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lblGreetings.Text = proxy.GetGreetings(txtName.Text);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;}&lt;br&gt;&lt;br&gt;&lt;/pre&gt;&lt;/div&gt;

Hit F5 to see the aspx page in browser. Input some name and hit Get
Greetings button, you should be able to see display output as shown in
fig below:


&lt;a href=&quot;http://bp3.blogger.com/_QsDuG4K936c/R_uLU3On5rI/AAAAAAAAGNE/mzqHU42vJ9Y/s1600-h/WCFHelloWorld-Part2_4.jpg&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;&quot; src=&quot;http://bp3.blogger.com/_QsDuG4K936c/R_uLU3On5rI/AAAAAAAAGNE/mzqHU42vJ9Y/s320/WCFHelloWorld-Part2_4.jpg&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5186892586386187954&quot; border=&quot;0&quot;&gt;&lt;/a&gt;


that&#39;s it.. simple to create a web cilent and consume a WCF service. I
will take you in depth in next part of this series, until then bye.</description>
    
    <category domain="http://www.purushotam.com/blog">Main Page</category>
    
    <category domain="http://www.purushotam.com/blog/WCF">WCF</category>
    
    
    
    
  </item>
  
  <item>
    <dc:creator>purushotam</dc:creator>
    <title>WCF Hello World Part -1</title>
    <link>http://www.purushotam.com/blog/_archives/2008/4/3/3744841.html</link>
    <guid>http://www.purushotam.com/blog/_archives/2008/4/3/3744841.html</guid>
    <pubDate>Thu, 03 Apr 2008 21:44:00 +0100</pubDate>
    <description>&lt;br&gt;This is my first posting on WCF, i thought I would start with Hello World on WCF and i dont know to what extent WCF will take me!. For a reader who finds this posting, this is would be a head start on WCF and am gonna discuss challenges and issues on WCF in part by part.so, here i am.first of all I would like to brief What tools i will be using at the moment.1. Visual Studio 2008 for this posting. I may wish to revisit this part again for my next posting.Ok then. Lets fire up Visual Studio 2008 and create WCF Service by name WCFHelloWorld as shown in fig below:&lt;a href=&quot;http://bp0.blogger.com/_QsDuG4K936c/R_U9LnOn5hI/AAAAAAAAGL0/pZcRtWkUGV4/s1600-h/WCFHelloWorld_1.jpg&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;&quot; src=&quot;http://bp0.blogger.com/_QsDuG4K936c/R_U9LnOn5hI/AAAAAAAAGL0/pZcRtWkUGV4/s320/WCFHelloWorld_1.jpg&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5185117815705167378&quot; border=&quot;0&quot;&gt;&lt;/a&gt;So When i have created, Visual Studio creates some files for me. those are1. Service1.svc2. IService1.cs3. Web.Config4. App_Code folder with web project settings and references.What might interests is 2 files 1 and 2 from above. In eariler version of .Net, you would have created Web Services and seen asmx files instead.now, I am gonna rename those files to fit into my demonstration as WCFHelloWorld.So, I rename Service1.svc as WCFHelloWorld.svc and IService1.cs as IWCFHelloWorld.cs.I leave it with you, how you rename the files and organise and make it compilable at least for now. finally i get my compilable as shown below:&lt;a href=&quot;http://bp1.blogger.com/_QsDuG4K936c/R_U_93On5iI/AAAAAAAAGL8/6ZMDlaV5mew/s1600-h/WCFHelloWorld_2.jpg&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;&quot; src=&quot;http://bp1.blogger.com/_QsDuG4K936c/R_U_93On5iI/AAAAAAAAGL8/6ZMDlaV5mew/s320/WCFHelloWorld_2.jpg&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5185120878016849442&quot; border=&quot;0&quot;&gt;&lt;/a&gt;&lt;div style=&quot;border: 1px solid rgb(218, 218, 218); padding-left: 5px;&quot;&gt;Note: &lt;em&gt;Keep in mind that WCF is a runtime for Web Services. In earlier versions of .Net, Asp.Net was runtime for Web Services.&amp;nbsp; now WCF is runtime for Web Services and .Net remoting!. Those who have worked on .Net Remoting, here is a good news, now they can enjoy exploring separate runtime!.&lt;/em&gt;&lt;/div&gt;When you build is succeeded, press F5 and opens in browser as shown below:&lt;a href=&quot;http://bp0.blogger.com/_QsDuG4K936c/R_aLyXOn5jI/AAAAAAAAGME/agwTCuoe4Pg/s1600-h/WCFHelloWorld_3.jpg&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;&quot; src=&quot;http://bp0.blogger.com/_QsDuG4K936c/R_aLyXOn5jI/AAAAAAAAGME/agwTCuoe4Pg/s320/WCFHelloWorld_3.jpg&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5185485718308775474&quot; border=&quot;0&quot;&gt;&lt;/a&gt;At this moment, I have created web service and launched it. In next part of this demo, will create a client and consume this web service.I have tried to make it simple, hence have not been able to delve in detail but taking this as an example, in some part later of this demo will go in depth,&amp;nbsp; until then bye...&lt;br&gt;&lt;br&gt;&lt;div style=&quot;text-align: center;&quot;&gt;----------------end of part -1 ------------&lt;/div&gt;</description>
    
    <category domain="http://www.purushotam.com/blog">Main Page</category>
    
    <category domain="http://www.purushotam.com/blog/WCF">WCF</category>
    
    
    <ent:cloud ent:href="">
    
    <ent:topic ent:id="Hello" ent:href="http://www.purushotam.com/blog/cmd=search_keyword/k=Hello">Hello</ent:topic>
    
    <ent:topic ent:id="WCF" ent:href="http://www.purushotam.com/blog/cmd=search_keyword/k=WCF">WCF</ent:topic>
    
    <ent:topic ent:id="World" ent:href="http://www.purushotam.com/blog/cmd=search_keyword/k=World">World</ent:topic>
    
    </ent:cloud>
    
    
    
  </item>
  
  <item>
    <dc:creator>purushotam</dc:creator>
    <title>SQL SERVER - Fix : Error : 40 - could not open a connection to SQL server</title>
    <link>http://www.purushotam.com/blog/_archives/2007/12/8/3744831.html</link>
    <guid>http://www.purushotam.com/blog/_archives/2007/12/8/3744831.html</guid>
    <pubDate>Sat, 08 Dec 2007 20:38:00 +0000</pubDate>
    <description>&lt;br&gt;
&lt;!--
 /* Font Definitions */
 @font-face
	{font-family:&quot;Cambria Math&quot;;
	panose-1:2 4 5 3 5 4 6 3 2 4;
	mso-font-charset:1;
	mso-generic-font-family:roman;
	mso-font-format:other;
	mso-font-pitch:variable;
	mso-font-signature:0 0 0 0 0 0;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;
	mso-font-charset:0;
	mso-generic-font-family:swiss;
	mso-font-pitch:variable;
	mso-font-signature:-1610611985 1073750139 0 0 159 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-unhide:no;
	mso-style-qformat:yes;
	mso-style-parent:&quot;&quot;;
	margin-top:0cm;
	margin-right:0cm;
	margin-bottom:10.0pt;
	margin-left:0cm;
	line-height:115%;
	mso-pagination:widow-orphan;
	font-size:11.0pt;
	font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;
	mso-ascii-font-family:Calibri;
	mso-ascii-theme-font:minor-latin;
	mso-fareast-font-family:Calibri;
	mso-fareast-theme-font:minor-latin;
	mso-hansi-font-family:Calibri;
	mso-hansi-theme-font:minor-latin;
	mso-bidi-font-family:&quot;Times New Roman&quot;;
	mso-bidi-theme-font:minor-bidi;
	mso-fareast-language:EN-US;}
.MsoChpDefault
	{mso-style-type:export-only;
	mso-default-props:yes;
	mso-ascii-font-family:Calibri;
	mso-ascii-theme-font:minor-latin;
	mso-fareast-font-family:Calibri;
	mso-fareast-theme-font:minor-latin;
	mso-hansi-font-family:Calibri;
	mso-hansi-theme-font:minor-latin;
	mso-bidi-font-family:&quot;Times New Roman&quot;;
	mso-bidi-theme-font:minor-bidi;
	mso-fareast-language:EN-US;}
.MsoPapDefault
	{mso-style-type:export-only;
	margin-bottom:10.0pt;
	line-height:115%;}
@page Section1
	{size:595.3pt 841.9pt;
	margin:72.0pt 72.0pt 72.0pt 72.0pt;
	mso-header-margin:35.4pt;
	mso-footer-margin:35.4pt;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
--&gt;


Recently i was setting up development environment at home.
When i had to connect SQL server remotely from another VPC, i could not connect
it even after enabling allow remote connections on my Sql Server. the error
messaage was...

&amp;nbsp;

An error has occurred while establishing a connection to the
server. When connecting to SQL Server 2005, this failure may be caused by the
fact that under the default settings SQL Server does not allow remote
connections. (provider: SQL Network Interfaces, error: 26 - Error Locating
Server/Instance Specified)

&amp;nbsp;&amp;nbsp;

&lt;br&gt;&amp;nbsp;for some reason it did not work as suggested by many..

&amp;nbsp;

but after banging my head to wall... cpu and then to lcd
monitor, figured the solution.

&amp;nbsp;

but dont worry, figured what was the problem at last………&amp;nbsp;

&lt;br&gt;&lt;br&gt;&lt;br&gt;&amp;nbsp;the probelm is the Instance name from the client is not
resolved, to do that follow the below shown steps.

&amp;nbsp;

&lt;br&gt;1. Navigate to C:\Windows\System32\drivers\etc

&lt;br&gt;2. Open hosts file in notepad

&lt;br&gt;3. Add the entry at the end of line, as i did for example

&amp;nbsp;

192.168.131.65 KSSQLSRVR

192.168.131.65 KSSQLSRVR\SPDEV01&amp;nbsp;

&lt;br&gt;&amp;nbsp;those were my instances i am tried to connect remotely

&amp;nbsp;
&lt;br&gt;&lt;br&gt;sweeeeet... it worked!

&amp;nbsp;

should work for anyone who have this problem...</description>
    
    <category domain="http://www.purushotam.com/blog">Main Page</category>
    
    <category domain="http://www.purushotam.com/blog/SQLServer">SQL Server</category>
    
    
    
    
  </item>
  
  <item>
    <dc:creator>purushotam</dc:creator>
    <title>Setting up different Authentication models in WSS 3.0 - Part 1</title>
    <link>http://www.purushotam.com/blog/_archives/2007/11/5/3744810.html</link>
    <guid>http://www.purushotam.com/blog/_archives/2007/11/5/3744810.html</guid>
    <pubDate>Mon, 05 Nov 2007 23:11:00 +0000</pubDate>
    <description>&lt;!--
 /* Font Definitions */
 @font-face
	{font-family:&quot;Cambria Math&quot;;
	panose-1:2 4 5 3 5 4 6 3 2 4;
	mso-font-charset:1;
	mso-generic-font-family:roman;
	mso-font-format:other;
	mso-font-pitch:variable;
	mso-font-signature:0 0 0 0 0 0;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;
	mso-font-charset:0;
	mso-generic-font-family:swiss;
	mso-font-pitch:variable;
	mso-font-signature:-1610611985 1073750139 0 0 159 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-unhide:no;
	mso-style-qformat:yes;
	mso-style-parent:&quot;&quot;;
	margin-top:0cm;
	margin-right:0cm;
	margin-bottom:10.0pt;
	margin-left:0cm;
	line-height:115%;
	mso-pagination:widow-orphan;
	font-size:11.0pt;
	font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;
	mso-ascii-font-family:Calibri;
	mso-ascii-theme-font:minor-latin;
	mso-fareast-font-family:Calibri;
	mso-fareast-theme-font:minor-latin;
	mso-hansi-font-family:Calibri;
	mso-hansi-theme-font:minor-latin;
	mso-bidi-font-family:&quot;Times New Roman&quot;;
	mso-bidi-theme-font:minor-bidi;
	mso-fareast-language:EN-US;}
.MsoChpDefault
	{mso-style-type:export-only;
	mso-default-props:yes;
	mso-ascii-font-family:Calibri;
	mso-ascii-theme-font:minor-latin;
	mso-fareast-font-family:Calibri;
	mso-fareast-theme-font:minor-latin;
	mso-hansi-font-family:Calibri;
	mso-hansi-theme-font:minor-latin;
	mso-bidi-font-family:&quot;Times New Roman&quot;;
	mso-bidi-theme-font:minor-bidi;
	mso-fareast-language:EN-US;}
.MsoPapDefault
	{mso-style-type:export-only;
	margin-bottom:10.0pt;
	line-height:115%;}
@page Section1
	{size:595.3pt 841.9pt;
	margin:72.0pt 72.0pt 72.0pt 72.0pt;
	mso-header-margin:35.4pt;
	mso-footer-margin:35.4pt;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
--&gt;


&lt;a href=&quot;http://bp2.blogger.com/_QsDuG4K936c/R0rqe0EXv3I/AAAAAAAAGHs/UYWXoAN_4Vo/s1600-h/b6.JPG&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;&quot; src=&quot;http://bp2.blogger.com/_QsDuG4K936c/R0rqe0EXv3I/AAAAAAAAGHs/UYWXoAN_4Vo/s320/b6.JPG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5137176140063424370&quot; border=&quot;0&quot;&gt;&lt;/a&gt;

&amp;nbsp;

Setting up different Authentication models in WSS3.0

Currently WSS 3.0 supports following authentication models
for intranet, extranet and Internet environments for their partner
applications.

&amp;nbsp;

1. Windows

2. Forms

&amp;nbsp;

Forms authentication is preferred over windows
authentication for extranet environments. The WSS 3.0 supports following
Authentication providers.

&amp;nbsp;

1. Active Directory Membership Provider

2. SQL Membership provider

3. Single Sign On - SSO

&amp;nbsp;

In this article I have made an attempt to depict
Authentication using Active Directory membership provider. And another
challenging functionality implemented is, if for some reason, user can not
logon, the page would display the reason along with logon details like account
locked, expiry date and disabled features as shown in screen shot below:

&amp;nbsp;

&lt;a href=&quot;http://bp3.blogger.com/_QsDuG4K936c/R0rkkEEXvsI/AAAAAAAAGGU/W7qwpjzTsQc/s1600-h/b1.JPG&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;&quot; src=&quot;http://bp3.blogger.com/_QsDuG4K936c/R0rkkEEXvsI/AAAAAAAAGGU/W7qwpjzTsQc/s320/b1.JPG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5137169633187970754&quot; border=&quot;0&quot;&gt;&lt;/a&gt;

&amp;nbsp;

Hence I have divided this article as 3 parts.

Part 1: Develop and Implement Custom Login for Active
Directory

Part 2: Develop and Implement Custom Change Password for
Active Directory

&amp;nbsp;

&lt;h3&gt;&lt;strong&gt;Part 1: Develop and Implement Custom
Login for Active Directory&lt;/strong&gt;&lt;/h3&gt;

In order to implement this part, firstly I would need to
create a class library which would override Login page of sharepoint provided
page.

&amp;nbsp;

3. From Visual Studio, create a class library and name the
project&amp;nbsp; as
SharePoint.Authentication.Custom.ActiveDirectory.

&amp;nbsp;

4. Since I need to deploy onto SharePoint, I have thought that,
its better idea to put this dll into GAC. So, from the properties of the
Project, under Signing tab, create a new snk and check delay sign.

&amp;nbsp;

&lt;a href=&quot;http://bp1.blogger.com/_QsDuG4K936c/R0rk7kEXvtI/AAAAAAAAGGc/5uP8qg16f24/s1600-h/b4.JPG&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;&quot; src=&quot;http://bp1.blogger.com/_QsDuG4K936c/R0rk7kEXvtI/AAAAAAAAGGc/5uP8qg16f24/s320/b4.JPG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5137170036914896594&quot; border=&quot;0&quot;&gt;&lt;/a&gt;

&amp;nbsp;

5. Rename the class1.cs to CustomLoginPage.cs

6. Add a reference from .Net&amp;nbsp;
tab, select Windows SharePoint Services as shown below:

&amp;nbsp; 

&lt;a href=&quot;http://bp0.blogger.com/_QsDuG4K936c/R0rlPUEXvuI/AAAAAAAAGGk/K619H8Ja-wQ/s1600-h/b5.JPG&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;&quot; src=&quot;http://bp0.blogger.com/_QsDuG4K936c/R0rlPUEXvuI/AAAAAAAAGGk/K619H8Ja-wQ/s320/b5.JPG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5137170376217312994&quot; border=&quot;0&quot;&gt;&lt;/a&gt;

&amp;nbsp;

7. Add a reference from .Net&amp;nbsp;
tab and browse to Microsoft.SharePoint.ApplicationPages.dll located in
C:\Program Files\Common Files\Microsoft Shared\web server
extensions\12\CONFIG\BIN\

&amp;nbsp;

&lt;a href=&quot;http://bp0.blogger.com/_QsDuG4K936c/R0rliUEXvvI/AAAAAAAAGGs/Y9rtRzC9Dgc/s1600-h/b2.JPG&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;&quot; src=&quot;http://bp0.blogger.com/_QsDuG4K936c/R0rliUEXvvI/AAAAAAAAGGs/Y9rtRzC9Dgc/s320/b2.JPG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5137170702634827506&quot; border=&quot;0&quot;&gt;&lt;/a&gt;

&amp;nbsp;

8. Add a reference&amp;nbsp;
from COM tab, Active DS Library. 

&amp;nbsp;

&lt;a href=&quot;http://bp0.blogger.com/_QsDuG4K936c/R0rluUEXvwI/AAAAAAAAGG0/tW7pIfkwSC4/s1600-h/b3.JPG&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;&quot; src=&quot;http://bp0.blogger.com/_QsDuG4K936c/R0rluUEXvwI/AAAAAAAAGG0/tW7pIfkwSC4/s320/b3.JPG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5137170908793257730&quot; border=&quot;0&quot;&gt;&lt;/a&gt;

&amp;nbsp;

9. Add a reference from .Net tab, System.Web,
System.DirectoryServices

&amp;nbsp;

10. In class CustomLoginPage.cs, add the following entries
in the namespace section

Using Microsoft.SharePoint;

Using ActiveDs;

11. Now, we are ready to start making some changes to the
class file.

12. Inherit the class from
Microsoft.SharePoint.ApplicationPages.LoginPage class

13. Since we are interested to know logon details on error,
I am gonna override on error event of Login page.as shown below

&amp;nbsp;

&lt;div&gt;&lt;pre style=&quot;border: 1px solid rgb(218, 218, 218); padding: 5px; overflow: scroll; font-family: &#39;Courier New&#39;,Monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 100%; line-height: normal; font-size-adjust: none; font-stretch: normal; width: 95%; height: 300px; color: rgb(102, 153, 51); background-color: rgb(240, 240, 240);&quot;&gt;&amp;nbsp;&lt;br&gt;&lt;br&gt;protected override void OnLoad(EventArgs e)&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;this.login.LoginError += new EventHandler(login_LoginError);&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;base.OnLoad(e);&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&lt;br&gt;&amp;nbsp;&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; void&lt;br&gt;login_LoginError(object sender, EventArgs e)&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { }&lt;br&gt;&lt;br&gt;&lt;/pre&gt;&lt;/div&gt;

14. In the above event handler, I would need to call login
details if user can not logon. Hence for the simplicity, I have created a
simple class and then populated data. Below show is the class.

&lt;div&gt;&lt;pre style=&quot;border: 1px solid rgb(218, 218, 218); padding: 5px; overflow: scroll; font-family: &#39;Courier New&#39;,Monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 100%; line-height: normal; font-size-adjust: none; font-stretch: normal; width: 95%; height: 300px; color: rgb(102, 153, 51); background-color: rgb(240, 240, 240);&quot;&gt;public class ADResult&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;br&gt;ADResult() { }&lt;br&gt;&lt;br&gt;&amp;nbsp;&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private bool&lt;br&gt;_locked;&lt;br&gt;&lt;br&gt;&amp;nbsp;&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public bool&lt;br&gt;Locked&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; get {&lt;br&gt;return _locked; }&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set {&lt;br&gt;_locked = value; }&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&lt;br&gt;&amp;nbsp;&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;private bool _disabled;&lt;br&gt;&lt;br&gt;&amp;nbsp;&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public bool&lt;br&gt;Disabled&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; get {&lt;br&gt;return _disabled; }&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set {&lt;br&gt;_disabled = value; }&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&lt;br&gt;&amp;nbsp;&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private string&lt;br&gt;_lastLogon;&lt;br&gt;&lt;br&gt;&amp;nbsp;&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string&lt;br&gt;LastLogon&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; get {&lt;br&gt;return _lastLogon; }&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set {&lt;br&gt;_lastLogon = value; }&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&lt;br&gt;&amp;nbsp;&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private&lt;br&gt;int&amp;nbsp; _expiresIn;&lt;br&gt;&lt;br&gt;&amp;nbsp;&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;br&gt;int&amp;nbsp; ExpiresIn&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; get {&lt;br&gt;return _expiresIn; }&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set {&lt;br&gt;_expiresIn = value; }&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&lt;br&gt;&amp;nbsp;&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private string&lt;br&gt;_errorMessage;&lt;br&gt;&lt;br&gt;&amp;nbsp;&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string&lt;br&gt;ErrorMessage&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; get {&lt;br&gt;return _errorMessage; }&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set {&lt;br&gt;_errorMessage = value; }&lt;br&gt;&lt;br&g