create a property for that WebPart

 

  1. I assume you already know how to create your own WebParts in SharePoint and is looking for some way to create a property for

that WebPart that you can easily Set and Get from your application, like the one on the image below:

 


  1. First, on your WebPart class (yellow highlight), and not the User Control class (green highlight), define your properties:


  2. For this example, I will show you how to define a text, boolean, integer, date/time, and enumeration property:

[ToolboxItemAttribute(false)]

public
class Sample_Web_Part : WebPart

{


// Visual Studio might automatically update


// this path when you change the Visual Web Part project item.


private
const
string _ascxPath =


@”~/_CONTROLTEMPLATES/Sample_Project/” +


@”Sample Web Part/Sample Web PartUserControl.ascx”;

 


protected
override
void
CreateChildControls()

{

Control control = Page.LoadControl(_ascxPath);

Controls.Add(control);

}

 


public
static
Boolean SampleBoolean;

[Category("Extended Settings"),

Personalizable(PersonalizationScope.Shared),

WebBrowsable(true),

WebDisplayName("Sample Boolean"),

WebDescription("Please Choose a Sample Boolean")]


public
Boolean _SampleBoolean

{


get { return SampleBoolean; }


set { SampleBoolean = value; }

}

 


public
static
string SampleText;

[Category("Extended Settings"),

Personalizable(PersonalizationScope.Shared),

WebBrowsable(true),

WebDisplayName("Sample Text"),

WebDescription("Please Enter a Sample Text")]


public
string _SampleText

{


get { return SampleText; }


set

{


// Sample Validation

Regex oRegEx = new Regex(“[a-zA-Z]+”);


if (!oRegEx.IsMatch(value))


throw
new Microsoft.SharePoint.WebPartPages.


WebPartPageUserException(


“Please enter alphabeth characters only”);

SampleText = value;

}

}

 


public
static
int SampleNumber;

[Category("Extended Settings"),

Personalizable(PersonalizationScope.Shared),

WebBrowsable(true),

WebDisplayName("Sample Number"),

WebDescription("Please Enter a Sample Number")]


public
int _SampleNumber

{


get { return SampleNumber; }


set { SampleNumber = value; }

}

 


public
static DateTime SampleDate;

[Category("Extended Settings"),

Personalizable(PersonalizationScope.Shared),

WebBrowsable(true),

WebDisplayName("Sample Date"),

WebDescription("Please Enter a Sample Date")]


public DateTime _SampleDate

{


get { return SampleDate; }


set { SampleDate = value; }

}

 


public
enum CityEnum { Manila, Berlin, Auckland, Zurich };


public
static CityEnum SampleDropDown;

[Category("Extended Settings"),

Personalizable(PersonalizationScope.Shared),

WebBrowsable(true),

WebDisplayName("Sample Drop Down"),

WebDescription("Please Choose a Sample DropDown")]


public CityEnum _SampleDropDown

{


get { return SampleDropDown; }


set { SampleDropDown = value; }

}

}

  1. If you notice, each property you create has attributes:
  • Category – This will group your property according to category. If not declared, “Miscellaneous” will be used as the default.
  • Personalizable – How the WebPart is configured, which can be per-user (PersonalizationScope.User), or for everyone (PersonalizationScope.Shared). For this example, we have chosen all users.
  • WebBrowsable – This will hide or show the property on the tool pane.
  • WebDisplayName – Label for the property.
  • WebDescription – Description for the property.
  1. You might also notice that we have validation on the codes. You can add your own like the one on the SampleText
    property where we implemented a Regular Expression, or even in
    SampleNumber. It is by default validated by its type so you cannot save once it has illegal values.


  2. So the final step is consuming that property in your WebPart; you can do it easily like:.


 

SharePoint Real Time Job oriented training

We have started best and complete training on Microsoft SharePoint Server 2010, which focus on some specific topic including Portals, Collaboration, Enterprise Search, Enterprise Content Management, and Business Intelligence. SharePoint 2010 provides a single and integrated location where employees can efficiently collaborate with team members, find organizational resources, search for experts and corporate information, manage content and workflow, and leverage business insight to make better-informed decisions. The goal of our training program is to provide the world with skilled human resources who are competent to practice and provide solutions in an ever-changing technological world.

Our Training-Cum-Office environment approach program provides 100% office environment to all the candidates.

SharePoint 2010 Social Ratings

Provides new feature to users to rate the site content list items like documents, blogs, tasks, discussion items etc. It’s available only with SharePoint 2010 and not with the Windows Foundation Services.

Let’s see how to use the rating feature. I will use social rating on the discussion board list in this article, but the procedure remains same for the rest of the lists.

Follow the below steps to enable rating.

  1. Enable Ratings Feature, It’s a hidden site feature, make sure it’s activated.

To activate using PowerShell: Open SharePoint 2010 Management Shell and type the below


  1. Enable Ratings on the list by using the List Settings >> Rating Settings


     

  2. Select “Yes” on the, Allow items in the list to be rated option.

     


  3. Rating (0-5), Rating Average columns gets added to the list, and in corresponding views.


  4. Start rating on the discussion board item. The same procedure applies for other lists also.

Why my ratings are not getting reflected instantly?

Ratings works with the help of the two timer jobs listed below

  • User Profile Service – Social Data Maintenance Job
  • User Profile Service – Social Rating Synchronization Job

These two timer jobs are responsible for synchronizing rating values between the Social Database and the Content Database. By default it’s configured on default interval. Change the interval to desired minutes will allow the timer job run more frequently and synchronize the rating data quickly.


 

Getting started with LINQ to SharePoint in SharePoint 2010

Introduction

In SharePoint 2010 you now have the ability to use LINQ syntax to fetch items from your lists instead of using the “traditional” approach of CAML queries. (Including SPSiteDataQuery and SPQuery objects)

LINQ to SharePoint!

In order to work with LINQ in SharePoint 2010, we need use a tool called SPMetal.exe which resides in the 14bin folder. This tool is used to generate some entity classes which Visual Studio 2010 can use to get IntelliSense, and allows for LINQ-based queries to be performed on your lists.

  • LINQ to SharePoint queries are translated to proper CAML queries
  • CAML queries are in turn later translated to SQL queries

SPMetal.exe

Using the tool called SPMetal, we generate our entity-classes that are needed to perform these object oriented queries toward our SharePoint server.

These are the required steps to get hooked up:

  1. Launch a cmd-window and navigate to C:Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\bin

    1. Run the following command to utilize the SPMetal.exe tool with the following syntax:
      1. spmetal.exe /web:http://nexus-l6:503 /code:c:\EntityModuleSharePoint.cs /user:nexus-l6\nexus /password:XXXXXXX
        /namespace:EntityModuleSharePoint
      2. Example:


     

    1. Now navigate to C: (or wherever you chose to output your file) and make sure the file has been generated


  1. Open up the file and take a look at the content that SPMetal now have provided us with:


Note that the class name is now EntityModuleSharePointDataContext. It’s based on the name you specify as your code file in the SPMetal.exe command line tool.

If you were to use /code:C:\EntityModuleSharePoint.cs instead, it would generate a class called EntityModuleSharePointDataContext.

 

  1. Visual Studio 2010 – Let’s create a sample Web Part that utilizes LINQ to SharePoint

    1. Create a new project (I’m going to create a new Visual Web Part project)
    2. Import your DataContext-file by choosing your Project -> Add -> Existing Item:
    3. Specify your file (mine is called EntityModuleSharePoint.cs):
    4. Make sure it’s properly placed in your project structure – then we’re good to go:

       


 

 

 

 

 

 

 

   Â
 

 

 

  1. Add proper references

    Now in order to use LINQ to SharePoint, you also need to reference the Microsoft.SharePoint.Linq assembly.

    Point to references, right-click and choose “Add Reference” and select the Microsoft.SharePoint.Linq.dll file:



 

  1. In your code, reference the assemblies:


  2. Code Sample


     

  3. Output:


Telerik (Version=2011.3.1115.35) with SharePoint

 

  1. Drag and drop Telerik.Web.UI.dll and Telerik.Web.Design.dll into C:\Windows\Assembly (in Windows Explorer) & reset IIS

     

  2. Go to Web.config file of Running Site; add this tag under <controls>

     

<add tagPrefix=”asp” namespace=”System.Web.UI.WebControls” assembly=”System.Web.Extensions, Version=3.5.0.0, Culture=neutral,

PublicKeyToken=31BF3856AD364E35″/>

 

 


 

 

  1. Find <SafeControls> & add this tag under <SafeControls>

 

<SafeControl Assembly=”Telerik.Web.UI, Version=2011.3.1115.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4″

Namespace=”Telerik.Web.UI” TypeName=”*” Safe=”True” />

 

 


 

 

 

 

 

  1. In Master Page
    1. Register control

     

    <%@ register tagprefix=”telerik” namespace=”Telerik.Web.UI” assembly=”Telerik.Web.UI,

    Version=2011.3.1115.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4″ %>


     

    1. Change Navigation control

    <telerik:RadMenu ID=”RadMenu1″ runat=”server” DataSourceID=”topSiteMap” EnableRoundedCorners=”true” EnableShadows=”true”/>

     


 

  1. OUT PUT


Create Manage Path For personal Site And Projects Site

  1. Create Manage Path for Personal Site & Projects Site.
    1. Go to Central Administration Site -> Click on” Manage Web Applications”

     


    1. Select “Site ” & Click on “Managed Paths


 

  1. Enter “Projects” under Path & Select “Wildcard inclusion” under Type & Click on “Add Path


 

  1. Enter “personal” under Path & Select “Wildcard inclusion” under Type

 

  1. Click on “Add Path”


  1. Click “Ok”


 

 

  1. Must be Started User Profile Sync Services.
    1. Click on Central Administration -> Click on “Manage Services on Server”


  1. Find “User Profile synchronization service” & Click on “Start


 

  1. Enter password of “sp2010\spfram ”


  1. Click “Ok”


 

 

  1. Going on Starting, its take time , depend on server configuration.


  1. This Service must be Started


  1. Configure My Site under User Profile Service.
    1. Click on Application Management


    1. Find “User Profile Service Application” & “Click


Click on “Setup My Sites”


  1. Verify My Site Host URL (http://sp1:80 )& Personal Site Location (Personal)

 


 

 

  1. Checked “Enable newsfeed on My Sites” & Click “Ok”


  1. Feed Activity Jobs
    1. Click on “Monitoring”


  2. review Jobs Definition”


    1. Scroll Down


 

  1. Find “User Profile Service Application – Activity Feed Job” & Click


  1. Click on ” minutes” & Click “Ok”


 

Deploy WSP Step

 

WSP Deployment STEP

  1. Go to-> start ->Microsoft SharePoint 2010 Products->SharePoint 2010 Management Shell- (Run As Administrator)


 

  1. Type one by one Command on “SharePoint 2010 management Shell” command is below mentioned.


For Add WSP’s

stsadm.exe -o addsolution -filename c:\wsp\selinks.wsp

For Deploy WSP’s

stsadm.exe -o deploysolution -name MySharePointSolution.wsp -url http://server -immediate –allowgacdeployment

We used the following commands to retract and delete a specific solution from the web application:

For Retract/Delete WSP’s

stsadm –o retractsolution –name MySharePointSolution.wsp –url http://server –immediate
stsadm –o deletesolution –name MySharePointSolution.wsp

For Active/Deactivate WSP’s

stsadm –o activatefeature –name MyFeatureName –url http://server
stsadm –o deactivatefeature –name MyFeatureName –url http://server

For Backup/Restore Command

stsadm.exe -o backup -url http://server -filename backup.dat –overwrite

stsadm.exe -o restore -url http://server -filename backup.dat

 


 

Create Application And Collection

  1. Go to “Central Administration” Site (Browser Must Run As Administrator)

  1. Click on “manage web applications”

 

 

  1. Select “SharePoint- 80” & Click on “Delete “

 

 

  1. Checked “Yes” on Delete content databases & Delete IIS web sites

  1. Click on “Delete”

  1. Click “Ok”

  1. Click on “Security”

  1. Click on “Register Managed Account”

 

 

  1. Enter User Name as “sp2010\spadmin” & Password as “soft@123

  1. Click “Ok”

 

  1. Click on “Central Administration”

  1. Click on “Manage Web Applications”

 

 

 

 

  1. Checked on “Claims Based Authentication

  1. Select “sp2010\spadmin” under Configurable

 

 

 

 

  1. Click “Ok”

  1. Processing please wait……………

 

 

  1. Right Click on “Create Site Collection”

  1. Open in New Browser tab

 

  1. Enter Title As “Test Site”

  1. Enter User name as “spadmin” & Click “Ok

 

 

  1. Top Level Site Successfully Created.

 

Install SharePoint

 

  1. Click on Computer

  2. Double Click on “DVD RW Drive

 

  1. Click on “Install Software prerequisites”

     

 

  1. Click on “Next”

 

  1. Checked “I Accept the terms of the License Agreement(s)” & Click “Next”

  2. Wait…………

 

  1. Click “Finish” Must be check all are installed successfully ,(if failed, Re-try)

  2. Click on “Install SharePoint Server

     

     

     

     

     

  3. Enter “Product Key” & Click “Continue

  4. Checked “I Accept the terms of this agreement” & Click “Continue”

     

 

  1. Click on “Server Farm”

  2. Checked “Complete- Installation all components. Can add Servers to form a SharePoint farm”

 

  1. Click “Install Now”

  2. Wait………….

     

 

  1. Uncheck “Run the SharePoint Products Configuration Wizard now”

  2. Click “Close”

     

     

     

     

     

  3. RUN SP1 of SharePoint 2010
  4. Double Click on Service Pack 1

  1. Checked ” Click here to accept the Microsoft Software License Terms” & Click “Continue”

 

  1. Wait…….

  1. Wait……..

  1. Wait………

  1. Now “The Installation is compete” & Click “Ok”

  1. Go to Start ->All Programs->Microsoft SharePoint 2010 Products->SharePoint Product s Configuration wizard

  1. Click on “Next”

 

 

 

  1. Click on “Yes”

  1. Checked “Create a new server farm”

 

  1. Click “Next”

  1. Enter Database Server is “sp1” , Username is “sp2010\spfarm” & Password is “soft@123

 

  1. Click “Next

  1. Enter Passphrase & conform Passphrase as “soft@123″

 

  1. Click “Next”

  1. Checked “Specify port number

 

 

 

  1. Enter “9090″

  1. Click “Next

 

  1. Wait…………

  1. Wait………

 

  1. Click on “Finish”

  1. Automatically Open Central Administration Web site.

 

  1. Checked “No”

  1. Click “Ok”

 

  1. Click on “Start the Wizard”

  1. Checked “Create new managed account

 

  1. Enter User name as”sp2010\spservices” & password “soft@123

  1. Wait……….

 

  1. Click on “Skip”

  1. Click on “Finish”

 

Install SQL Server

  1. System must be Login with “sp2010\spadmin”
  1. Click on “My Computer”

    1. Double Click on “DVD RW Drive”

     

    1. Click on “Ok”

       

    2. Click on “Installation”

     

    1. Click on “New Installation or add feature to an existing installation

     

    1. Click on “Ok”

     

    1. Enter “product Key” & Click “Next

    1. Checked “I Accept the license terms”

     

    1. Click “Next”

      1. “Click “Install”

      1. Wait…….

      1. Click on “Next”

      1. Checked “SQL Server Feature Installation”

      1. Checked “Database Engine Services, SQL Server Replication, Full Text Search under Instance Feature &
        Management Tools-Complete under Management Tools-Basic.

     

    1. Click on “Next”

    1. Click on “Next”

     

    1. Click “Next”

    Click “Next”

     

     

    1. Click on “Use the same account for all SQL Server services

    1. Enter the Account of SQL Services i.e. (SP2010\sqlsrvc)

    1. Click “OK”

    1. Click “Next”

    1. Click on “Add Current User”

     

     

     

    1. Click “Next”

    1. Click “Next”

     

    1. Click “Next”

    1. Click “Install”

     

    1. Wait………..

    1. Click “Close”

    Â