Saturday, December 19, 2009

SharePoint Solution Architecture

Solution Architecture

I am just going to share my thoughts on creating solution architecture for sharepoint application

Here I have created so many projects don't scare, you can change this according to your requirements

Normally I split solution based on requirements, but I would like to discuss general approach for SharePoint projects based on my knowledge I hope this will help you at least some part of your application




RSMTechno.CodeBehind
RSMTechno.Common
RSMTechno.Controls
RSMTechno.DataAccessLayer
RSMTecno.SolutionDemo
RSMTecno.BusinessLayer

RSMTechno.CodeBehind

I have created some page layouts and master page and deployed in to SharePoint environment , later I felt that I wanted to add some code to the master page to customize navigation bar…or some code to the sitepages,here I strucked because by default SharePoint will not generate code behind files to master page and site pages

So what I have to do?

Either I have to write inline code or I have to create separate class library and attach it to the master page or site pages

Suppose if I write inline code to the page and run the application everything works fine but if I customize the page using SharePoint designer and run the application there the problems comes because in SharePoint the customized page run through the safe mode parser, which will block any inline code from running

So what is the solution for this? what we have to follow to resolve this?

We need to follow second approach .

We have to create separate class library and register that in page using register tag , our RSMTechno.CodeBehind libarys is created for that it contains all the class files inherited from Microsoft.SharePoint.Publishing.PublishingLayoutPage or System.Web.UI.MasterPage or Sytem.web.UI.WebPartPage

Check the sample code provide below

Layout Page

using System;
using System.Web.UI;
using Microsoft.SharePoint.Publishing;

namespace RSMTechno.Pages {
public class RSMLayoutTemplate : PublishingLayoutPage {
}
}

WebPartPage


using System;
using System.Web.UI;
using Microsoft.SharePoint.Publishing;

namespace RSMTechno.Pages {
public class RSMWebPartPage: WebPartPage
{
}
}


RSMTechno.Common

This application is created mainly for utility methods and common functionally across all the functionality's like utility classes(ProfileUtility etc...)

RSMTechno.Controls

This library project is created mainly for creating custom controls
While creating webparts I prefer that first create custom control and create object for that in your webpart class ,the main advantage of this is in future suppose if your client want to shift to .net based application because of some reasons, he can easily move in to .net application because you have developed all the components using webcontrol class so you can reuse same controls in your .net application

Sometimes you may need to override dropdownlist or datagrid or any .net control to provide reusability you can use this project to handle such kind of exteded controls

I have provided sample code here

Custom Controls

Normal Custom Cotntrol

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace RSMTechno.Controls
{
[ToolboxData("<{0}:DemoControl =server>")]
public class DemoControl : WebControl
{
//create your control
protected override void OnInit(EventArgs e)
{
//add to controls collection
base.OnInit(e);
}
}

Extended controls

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace RSMTechno.Controls
{
[ToolboxData("<{0}:DropListwDefault runat=server>")]
public class ExtendedDropDownListwDefault : DropDownList
{

public ExtendedDropDownListwDefault()
{
DataTextField = "name";
DataValueField = "id";
this.AppendDataBoundItems = true;
AddDefault();
}

public void AddDefault()
{
ListItem defaultItem = new ListItem();
defaultItem.Selected = true;
defaultItem.Text = "--";
defaultItem.Value = Guid.Empty.ToString();
this.Items.Add(defaultItem);
}

}
}


WebParts class

namespace RSMTechno.WebParts
{
public class DemoControl : system.web.UI.WebControls.WebParts.WebPart
{

}
DemoControl _dc = null;
protected override void OnInit(EventArgs e)
{
_dc = new DemoControl();
this.Title = "Demo Control….";

this.Controls.Add(_dc);

base.OnInit(e);
}
}

RSMTechno.DataAccessLayer

I want to get data from other database servers and display it on web part, here we need to write a code to interact with different database servers this project library is created for that purpose only

You can find one dbml file which will interact with northwind database through LINQtoSQL

But, rarely we use this library project because MOSS has provided some OOTB functionality to interact with external database servers

RSMTecno.SolutionDemo

This is the heart of the solution; this will take care of all the things like installing the web parts, site definitions, master pages and user controls etc... using features

Here, you can find some folders which are mapped to exactly 12 hive folder structure in sharepoint environment like CONTROLTEMPLATES,RESOURCES,LAYOUTS and FEATURES etc...

While deploying what are all things you have placed uder these folder structure will be automatically dumped in to sharepoint 12 hive environment

I am using wspbuilder for building and deploying features

I have posted one article on how to build and deploy features using wspbuilder please go through that if you have any doubts

RSMTechno.BusinessLayer

This will seaparate your business logic and it provides more reusability and maintanence

Each and every component will interact with this to fetch data from sharepoint document library or list or xml file or from third party resources and populate accordingly


Some people asked me why I have to create five projects I will use one or two , yes ofcourse if you want you can use but what about maintenance and reusability just think?

Building solution is not a simple task you have to consider lot of things like maintenance, reusability,supports testdriven development etc...

Let us take this simple scenario in future, if I want to add one new control in to my sharepoint application? what are all things do I need to do? I will just go and simply create one server control under RSMTechno.Control project and build that project and deploy that assembly into GAC or BIN

See how much simple it is with out building or touching other components we are completing our task

There may be some delay passing objects from one layer to another layer but I feel that is not considered amount what ever you write that should be in reusable manner and should be easily maintenable

If you want you can add different projects in the solution like RSMTECHNO.WebServices etc... based on your requirements

But be carefull unnecessary if you pass your objects in multiple layers that will affect on performance

Friday, November 6, 2009

Best Practices while creating webparts

I would like to share some best practices on sharepoint while creating solution/implementation for sharepoint custom application

While creating webparts I prefer that first create custom control and create object for that in your webpart class ,the main advantage of this is in future , suppose if your client want to shift to .net based application because of some reasons, he can easily move in to .net application because you have developed all the components using webcontrol class so you can reuse same controls in your .net application

I have provided sample code here

Custom Controls

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace RSMTechno.Controls
{
[ToolboxData("<{0}:DemoControl =server>")]
public class DemoControl : WebControl
{
//create your control
protected override void OnInit(EventArgs e)
{
//add to controls collection
base.OnInit(e);
}
}

WebParts class

namespace RSMTechno.WebParts
{
public class DemoControl : system.web.UI.WebControls.WebParts.WebPart
{

}
DemoControl _dc = null;
protected override void OnInit(EventArgs e)
{
_dc = new DemoControl();
this.Title = "Demo Control….";

this.Controls.Add(_dc);

base.OnInit(e);
}
}

User controls

Usercontrols makes your development faster because no need of writing code in codebehind file for creating controls in webpart , I think every web developer will have some knowledge on html stuff so they can use html for desgining their GUI using VSIDE and they can immediately see output on screen mode, the main advantage of this is it will make your development faster when you have short deadlines

I think most of the .net guys aware of usercontrols , so need of puttingmore effort on writing in codebehind in webparts this will save time also

Suppose in future if you feel that sharepoint is not right platform for the solution you are building, you can easily move into other platform no need of putting extra effort on that and you can reuse your usercontrols

But only some people are saying that they are facing some performance problems when they use usercontrols in webparts that to in extremely large sites

WSPBiuilder

I always prefer to use wspbuilder to create features through VSIDE, because this tool will help you a lot

No need of manually creating manifest.xml , no need of specifying the DDF file so please please use wspbuilder if you want to make your sharepoint development faster

Actually when you want to uninstall your feature you have to use STSADM command or you have to use solution management to uninstall your future

But this tool will help you to install/uninstall futures through wizard; this will help those who don’t have knowledge on SharePoint

Tuesday, September 8, 2009

Creating PageLayouts using Features

Long time back I have posted an article on creating page layouts using SharePoint user interface and designer, now I am going to explain how to create page layouts using features

In this article, I am going to use WSPBuilder for building and deploying SharePoint solution, the main advantage of WSPBuilder is no need of creating manifest.xml , DDf file and cab file, the WSPBuilder will take care of creating all these things, so this will simplify our process

First, I am going to explain what are the entire things do we need for building SharePoint page layouts using features

Please check below image which talks about relation between Site Columns, Content Type and Page layout



Site Columns

A site column is a reusable column definition, or template, that you can assign to multiple lists across multiple SharePoint sites. These columns are directly mapped to table columns in SharePoint database

Her e I have created three columns Activity Name, Activity ID, Activity Image,
While creating site columns please make sure that each column have its own unique ID

You can get Unique ID using GUID tool

VS2008->Tools->Create GUID->Registry Format->Copy

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">

<Field ID="{d7bc4337-826c-497d-bd46-b7a14afb6a9c}"
Type="Text"
Name="ActivityName"
DisplayName="Activity Name"
StaticName="Activity Name"
Hidden="FALSE"
Required="FALSE"
Group="Activity Columns"
Sealed="FALSE" />
<Field ID="{8BA8E4BC-395F-4a7c-91D7-E9519CC41D11}"
Type="Text"
Name="Activity ID"
DisplayName="Activity ID"
StaticName="Activity ID"
Hidden="FALSE"
Group="Activity Columns"
Required="FALSE"
Sealed="FALSE" />
<Field ID="{EC61E44F-E3FC-430e-BA3A-F457A8945190}"
Type="Image"
Name="Activity Image"
DisplayName="Activity Image"
StaticName="Activity Image"
Hidden="FALSE"
Group="Activity Columns"
Required="FALSE"
Sealed="FALSE" />

</Elements>

Site Content Type


Suppose if you want to manage your organization information in meaning full way across site collection then you can go for Site content types

A content type is a reusable collection of settings you want to apply to a certain category of content. Content types enable you to manage the metadata and behaviors of a document or item type in a centralized, reusable way

Here I have created activity content type that tells to the client that this content type belongs to only activity information

Every content type has FieldRef properties, these properties have a reference to site columns ID’s, that means this field(Site Column)and FieldRef both are pointing to same reference, so whenever we update site column’s that will automatically reflect in content type columns also

See below code all FieldRef Id’s are pointing to sit columns ID’s, if you want you can override some of the properties name, description etc…

Using below code we have created a content type, this is simple content type, it does not do anything so, we have to attach this to base page content type using Content type ID

The content type ID is the combination of base page ID and custom GUID which are separated by 00

Please refer MSDN link for more info on content type id http://msdn.microsoft.com/en-us/library/aa543822.aspx

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ContentType ID="0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900088E14C620BF45afA8B4ADA5F771DB5D"
Name="ActivityContentType"
Group="Demo"
Description="Demo Content Type"
Version="0">
<FieldRefs>
<FieldRef ID="{d7bc4337-826c-497d-bd46-b7a14afb6a9c}" Name="Activity Name" />
<FieldRef ID="{8BA8E4BC-395F-4a7c-91D7-E9519CC41D11}" Name="Activity ID" />
<FieldRef ID="{EC61E44F-E3FC-430e-BA3A-F457A8945190}" Name="Activity Image" />
</FieldRefs>
</ContentType>
</Elements>

Layout page

I suggest you guys create layout page using SharePoint designer and copy into your feature folder, so that you will not face any kind of problems and your work will be smooth

Below page is the which I have created using SharePoint designer

All the SharePoint controls of this layout page have a reference to site columns using Fieldname property, the Fieldname is the name of the site column

<%@ Page language="C#" Inherits="Microsoft.SharePoint.Publishing.PublishingLayoutPage,Microsoft.SharePoint.Publishing,Version=12.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" meta:webpartpageexpansion="full" meta:progid="SharePoint.WebPartPage.Document" %>
<%@ Register Tagprefix="SharePointWebControls" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="PublishingWebControls" Namespace="Microsoft.SharePoint.Publishing.WebControls" Assembly="Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="PublishingNavigation" Namespace="Microsoft.SharePoint.Publishing.Navigation" Assembly="Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<asp:Content ContentPlaceholderID="PlaceHolderPageTitle" runat="server">
<SharePointWebControls:FieldValue id="PageTitle" FieldName="Title" runat="server"/>
</asp:Content>
<asp:Content ContentPlaceholderID="PlaceHolderMain" runat="server">

<SharePointWebControls:TextField FieldName="Activity ID" runat="server" id="TextField1">
</SharePointWebControls:TextField>
<SharePointWebControls:TextField FieldName="ActivityName" runat="server" id="TextField2">
</SharePointWebControls:TextField>
<PublishingWebControls:RichImageField FieldName="Activity Image" runat="server" id="RichImageField1">
</PublishingWebControls:RichImageField>

</asp:Content>


ProvisionedFiles.xml

I am using module element for deploying our page in master page gallery

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">

<Module Name="ActivityPage" Url="_catalogs/masterpage" Path="" RootWebOnly="TRUE">
<File Url="Activity.aspx" Type="GhostableInLibrary">
<Property Name="ContentType" Value="DemoContetType" />
<Property Name="PublishingPreviewImage" Value="~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/sample.png, ~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/sample.png" />
</File>
</Module >
</Elements>

Feature.xml

<?xml version="1.0" encoding="utf-8"?>
<Feature Id="c2554713-1770-4349-8576-c6f8fe44a950"
Title="PageLayoutDemo"
Description="Description for PageLayoutDemo"
Version="12.0.0.0"
Hidden="FALSE"
Scope="Site"
DefaultResourceFile="core"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>

<ElementManifest Location ="SiteColumns.xml"/>
<ElementManifest Location ="ContentType.xml"/>
<ElementManifest Location ="ProvisionedFiles.xml"/>

</ElementManifests>

</Feature>

So, we have created all necessary files which are required to create pagelayout, now we have to deploy all these files using features

I am using WSPBuilder for deploying all these files, I have posted an article on WSPBuilder please check it, if you need more info



Create a new WSPBuilder Project then create folder structure as shown in fig then copy all the files and build and deploy

For more info on WSPBUilder check my article on WSPBuilder

Friday, August 7, 2009

SPCustomContextMenu

Hi Guys!

Recently I have got some free time, so I thought of utilizing that time as technically, so I have designed and developed a reusable component for SharePoint list and library, this component will be very useful when you customizing context menu of list , document library and developing workflows

I have seen so many people using below code for customizing SharePoint list context menus. But just think about maintenance

function Custom_AddListMenuItems(m, ctx)
{
Return true;
}

If any changes come in future we need edit the page and modify the javascript and once again we need test that functionality, here we are wasting our valuable time

SPCustomContextMenu

So I have created a feature which will read the xml file and convert into custom context menu the main advantage of this is whenever you change xml file the changes will be automatically reflected in to your custom context menu

This will be very useful when you developing workflows because based on the status of workflow the context menu will change, the administrator will have full control on this no developer interaction

The XML schema looks like this


<?xml version="1.0" encoding="utf-8" ?>
<nodes>
<node>
<sourcefield>
<fieldname>status</fieldname>
<ifeq>open</ifeq>
</sourcefield>
<destfield>
<shownode>
<Name>Assign issue</Name>
<ImageUrl>/SiteCollectionImages/ppubicon.gif</ImageUrl>
<ActionLink>/Pages/TestPage.aspx</ActionLink>
</shownode>
</destfield>
</node>
<node>
<sourcefield>
<fieldname>status</fieldname>
<ifeq>assigned</ifeq>
</sourcefield>
<destfield>
<shownode>
<Name>In Progress</Name>
<ImageUrl>/SiteCollectionImages/ppubicon.gif</ImageUrl>
<ActionLink>/Pages/TestPage.aspx</ActionLink>
</shownode>
</destfield>
<destfield>
<shownode>
<Name>Paused</Name>
<ImageUrl>/SiteCollectionImages/ppubicon.gif</ImageUrl>
<ActionLink>/Pages/TestPage.aspx</ActionLink>
</shownode>
</destfield>
<destfield>
<shownode>
<Name>Set In Progress</Name>
<ImageUrl>/SiteCollectionImages/ppubicon.gif</ImageUrl>
<ActionLink>/Pages/TestPage.aspx</ActionLink>
</shownode>
</destfield>
</node>
<node>
<sourcefield>
<fieldname>status</fieldname>
<ifeq>in progress</ifeq>
</sourcefield>
<destfield>
<shownode>
<Name>Paused</Name>
<ImageUrl>/SiteCollectionImages/ppubicon.gif</ImageUrl>
<ActionLink>/Pages/TestPage.aspx</ActionLink>
</shownode>
</destfield>
<destfield>
<shownode>
<Name>Resolved</Name>
<ImageUrl>/SiteCollectionImages/ppubicon.gif</ImageUrl>
<ActionLink>/Pages/TestPage.aspx</ActionLink>
</shownode>
</destfield>
</node>
<node>
<sourcefield>
<fieldname>status</fieldname>
<ifeq>resolved</ifeq>
</sourcefield>
<destfield>
<shownode>
<Name>Re-Opened</Name>
<ImageUrl>/SiteCollectionImages/ppubicon.gif</ImageUrl>
<ActionLink>/Pages/TestPage.aspx</ActionLink>
</shownode>
</destfield>
<destfield>
<shownode>
<Name>Closed</Name>
<ImageUrl>/SiteCollectionImages/ppubicon.gif</ImageUrl>
<ActionLink>/Pages/TestPage.aspx</ActionLink>
</shownode>
</destfield>
</node>
<node>
<sourcefield>
<fieldname>status</fieldname>
<ifeq>re-opened</ifeq>
</sourcefield>
<destfield>
<shownode>
<Name>Assign issue</Name>
<ImageUrl>/SiteCollectionImages/ppubicon.gif</ImageUrl>
<ActionLink>/Pages/TestPage.aspx</ActionLink>
</shownode>
</destfield>
</node>
<node>
<sourcefield>
<fieldname>status</fieldname>
<ifeq>paused</ifeq>
</sourcefield>
<destfield>
<shownode>
<Name>Set in progress</Name>
<ImageUrl>/SiteCollectionImages/ppubicon.gif</ImageUrl>
<ActionLink>/Pages/TestPage.aspx</ActionLink>
</shownode>
</destfield>
</node>

</nodes>

Here the <sourcefield> tag talks about workflow status and <destfield> talks about what to display in custom context menu

I have a issue tracking list as shown in fig





After installing and activating the feature the issue tracking list looks like below see it displays custom context menu based on status of workflow




Using this feature you can modify your custom context menu in minutes

Please mail me for source code raja.mandalapu@gmail.com

Happy coding...

Long time back I have posted an article on creating page layouts using SharePoint user interface and designer, now I am going to explain how to create page layouts using features


In this article, I am going to use WSPBuilder for building and deploying SharePoint solution, the main advantage of WSPBuilder is no need of creating manifest.xml , DDf file and cab file, the WSPBuilder will take care of creating all these things, so this will simplify our process
First, I am going to explain what are the entire things do we need for building SharePoint page layouts using features


Site Columns


A site column is a reusable column definition, or template, that you can assign to multiple lists across multiple SharePoint sites. These columns are directly mapped to table columns in SharePoint database


Her e I have created three columns Activity Name, Activity ID, Activity Image,


While creating site columns please make sure that each column have its own unique ID
You can get Unique ID using GUID tool


VS2008->Tools->Create GUID->Registry Format->Copy





Type="Text"
Name="ActivityName"
DisplayName="Activity Name"
StaticName="Activity Name"
Hidden="FALSE"
Required="FALSE"
Group="Activity Columns"
Sealed="FALSE" />
Type="Text"
Name="Activity ID"
DisplayName="Activity ID"
StaticName="Activity ID"
Hidden="FALSE"
Group="Activity Columns"
Required="FALSE"
Sealed="FALSE" />
Type="Image"
Name="Activity Image"
DisplayName="Activity Image"
StaticName="Activity Image"
Hidden="FALSE"
Group="Activity Columns"
Required="FALSE"
Sealed="FALSE" />



Site Content Type


Suppose if you want to manage your organization information in meaning full way across site collection then you can go for Site content types


A content type is a reusable collection of settings you want to apply to a certain category of content. Content types enable you to manage the metadata and behaviors of a document or item type in a centralized, reusable way


Here I have created activity content type that tells to the client that this content type belongs to only activity information


Every content type has FieldRef properties, these properties have a reference to site columns ID’s, that means this field(Site Column)and FieldRef both are pointing to same reference, so whenever we update site column’s that will automatically reflect in content type columns also
See below code all FieldRef Id’s are pointing to sit columns ID’s, if you want you can override some of the properties name, description etc…


Using below code we have created a content type, this is simple content type, it does not do anything so, we have to attach this to base page content type using Content type ID


The content type ID is the combination of base page ID and custom GUID which are separated by 00


Please refer MSDN link for more info on content type id http://msdn.microsoft.com/en-us/library/aa543822.aspx




Name="ActivityContentType"
Group="Demo"
Description="Demo Content Type"
Version="0">









Layout page


I suggest you guys create layout page using SharePoint designer and copy into your feature folder, so that you will not face any kind of problems and your work will be smooth


Below page is the which I have created using SharePoint designer


All the SharePoint controls of this layout page have a reference to site columns using Fieldname property, the Fieldname is the name of the site column


<%@ Page language="C#" Inherits="Microsoft.SharePoint.Publishing.PublishingLayoutPage,Microsoft.SharePoint.Publishing,Version=12.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" meta:webpartpageexpansion="full" meta:progid="SharePoint.WebPartPage.Document" %>
<%@ Register Tagprefix="SharePointWebControls" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="PublishingWebControls" Namespace="Microsoft.SharePoint.Publishing.WebControls" Assembly="Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="PublishingNavigation" Namespace="Microsoft.SharePoint.Publishing.Navigation" Assembly="Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>














ProvisionedFiles.xml

I am using module element for deploying our page in master page gallery












Feature.xml

Title="PageLayoutDemo"
Description="Description for PageLayoutDemo"
Version="12.0.0.0"
Hidden="FALSE"
Scope="Site"
DefaultResourceFile="core"
xmlns="http://schemas.microsoft.com/sharepoint/">










So, we have created all necessary files which are required to create pagelayout, now we have to deploy all these files using features


I am using WSPBuilder for deploying all these files, I have posted an article on WSPBuilder please check it, if you need more info

Thursday, June 11, 2009

Using ApplicationDefinitionDesigner to create ADF files


In recent article I have explained some free tools which will make SharePoint development faster

Now, I am going to explain one more tool called ApplicationDefinitionDesigner. This tool will help you to generate ADF file without breaking your head

Business Data Catalogue

Actually the Business Data Catalogue will help you to integrate business data from back end servers such as SAP, Oracle etc… to the SharePoint environment without writing single line of code, for successful implementation of this we need to have an ADF file

Now, I am going to explain how easily we can generate ADF file using this tool
Go to -> Start -> Programs -> ADF -> Click on Connect to Database
It will open a new window with Connection Type and Connection String

Choose type of connection then enter connection string in connectionstring text box
Then Click on Connect




Now, you can see new window with Add Table tab and Add View tab as shown in fig

Then expand Add table tab and drag and drop whatever table you want, here I drag and dropped product table because I like products

Then uncheck unwanted cloumns and click on ok button

Congrats, u have successfully created ADF file using ADF tool

Now, I am going to show you how to test that ADF file

Just right click on method instance name as shown in fig and click on Execute button, it will open new window then enter ProductID and click on Execute button

Finally the results data grid will populate with output

Now, I am going to step into little complex things that is creating filter using ADF tool here I am going to add new filter called color

Expand Entities - > Methods -> Click on method name and edit the sqlquery as shown in fig


Next, right on Filters link and click add filter, it will add new filter and go to the properties box and change the name to Color

Next, Go to parameters link and click on add parameter and then go to properties box and change Name to @Color and right click on @Color and select “Add Root level Element” and then go to properties box and change Name to Color and then the important step is change “FilterDescriptor “ to Color

Once Again you have successfully created ADF file

Next step testing that ADF file

Right click on method name and click on execute, it will open new window, enter ID and Color Values and click on Execute


Hey, What happened to my ADF file why it is not executing I followed all the steps correctly but why that error is coming???

The answer is i have done a mistake at parameters declaration as shown in fig



So now I am going to change that using notepad

Just export this ADF file to desktop and find that element and move it to top

The problem is that the return parameter should be a last parameter

Now execute method it will work properly

Then export this to central administration and use it in your site collection Business data list webpart

Happy Coding…

Friday, May 29, 2009

Creating New Page Layouts

Usually sharepoint page layouts will work out in most of the requirements but what you will do if it does not meet your requirements you will have to create your own page layouts for use on the site

Creating page layout is accomplished in five steps

1. Define Site Columns
2. Define site Content Type
3. Create Page layout
4. Edit Page Layout
5. Publish and Approve Page Layout

I am going to create a new page layout called Activity page for demo, the main job of this is just to collect activity information from the administrator when it is in Edit mode and it displays data to the end user when it is in publishing mode

First i am going to define site columns these columns are directly mapped to the layout field controls on page

Define Site Columns

Site column is nothing but a reusable column that you can use in mulitple lists across multiple sites

Creating Site Column

1. Open SharePoint Site
2. Got to Site Actions
3. Site Settings
4. Galleries
5. Site Columns
6. Create
7. Enter the Activity Name under Column name textbox
8. Select type of column
9. Create new group called Activity group
10 . Select yes for require that this column contains information
11. i have taken default values for remining two which are Maximum number of charactersa and default value
12. click Ok

Repeat same steps for creating remaining site columns which are listed below

Activity Image - select type to image
Activity Description - select type to multiplie lines
Activity Workflow - select ype to image
Trainings - select type to single text

I hope that you are succesfully created remaining sitecoulmns our next step is creating Site Content Type

1. Open SharePoint Site
2. Got to Site Actions
3. Site Settings
4. Galleries
5. Site Content Types
6. Create

Please have a look into screenshot for remainig steps

Our next step is to create new Page Layout

1. Open SharePoint Site
2. Got to Site Actions
3. Site Settings
4. Galleries
5. Master pages and page layouts
6. Create



Follow the screen shot for remaining steps






Next, we have to edit the page layout using sharepoint designer



Go to Start -> Programs -> Microsoft Office -> Microsoft Office SharePoint Desinger2007 -> File -> Open Site... -> Enter site url


You can see checked-out activity page under master page gallery refer below screen shot






You can see all site coumns under Content Fields Section just drag and drop Activity Name ,Activity Descrption, Activity Workflow, activty Image and Trainings on to activity page


Next, just right click on activity page and click on check-in and select publish a major version


Next, click on yes

After clicking yes you will be automatically redirected to Master Page Gallery there you can find all pending files to approve

For approvning these files you should have a approvel permissons then right click on activity page and click on Approve/Reject link


It will open a new page with approved, rejected and pending options just click approved radio button and give proper comments and clikc on ok

We are successfully created new page layout our next step is to create a new page using this page layout

Site Actions -> Create Page

Now you can see "Activity page layout" under layout drop down list. Fill Title and URL name textboxes and click on create button you will get a new page with place holders just populate with data and click on publish button


Tuesday, May 26, 2009

I found something that when i bind SPGridView using SharePoint object model.
The strange thing is that if I use this code everything works fine

SPDataSource dataSource = GetTravelExpenses();
string sCommand = @"<Query><Where>
<Eq>
<FieldRef Name='Travel_x0020_Request' />
<Value Type='Lookup'>" + ddlTravelRequest.SelectedItem.Text + "</Value> </Eq> </Where></Query>";
dataSource.SelectCommand = sCommand;
spGrid.DataSource = dataSource;
spGrid.DataBind();

But when I use this code the CAML query is failing to get data from Travel Request List

SPDataSource dataSource = GetTravelExpenses();
string sCommand = @"<Where>
<Eq>
<FieldRef Name='Travel_x0020_Request' />
<Value Type='Lookup'>" + ddlTravelRequest.SelectedItem.Text + "</Value> </Eq> </Where>";
dataSource.SelectCommand = sCommand;
spGrid.DataSource = dataSource;
spGrid.DataBind();

I found the reason that the <Query></Query> element is missing in the second scenario finally I decided to check this with SPQuery i was shocked that everything works fine

SPQuery query = new SPQuery();
query.Query = @"<Where>
<Eq>
<FieldRef Name='Travel_x0020_Request' />
<Value Type='Lookup'>" + ddlTravelRequest.SelectedItem.Text + "</Value> </Eq> </Where>";

My question is why SPDataSource.SelectCommand is failing to get data from Travel Request List when i use CAML query without <Query></Query> element

If anybody knows answer please…………. share with me…

Wednesday, May 6, 2009

Microsoft SharePoint Server 2010

Microsoft is going to release Microsoft SharePoint Server 2010 to get more knowledge on this click here

Monday, May 4, 2009

IE Crashes when ever my client check-out a file from document library

Today morning my client has come up with a problem that when he tries to check-out or check-in a document from a document library, he was getting strange error message, the IE was not able to open Word document, that too it was coming only for few employees





After seeing end user environment details i find out that they have installed offcie2003 along with office 2007 on same computer

Usually this problem occurs when you install one or more 2007 Office system programs on the computer along with office2003.

Microsoft provides Hot-fix for this problem you can download it using this link http://support.microsoft.com/kb/938888

After installing this hot-fix everything works fine

SharePoint Media Streaming WebPart

Recently I have implemented media streaming web part (YouTube technology) for one of my client, I would like to share this with you guys

This I have developed for one of my client so, I am not going to share code with you guys.

Media streaming web part uses windows media server for playing media files because It is especially useful for streaming large amounts of data over busy, congested networks and low-bandwidth connections. Streaming uses bandwidth more efficiently than downloading because it sends data over the network only at the speed that is necessary for the client to render it correctly. This helps prevent the network from becoming overloaded and helps maintain system reliability.

If you want to know more about windows media server please refer this article http://learn.iis.net/page.aspx/454/windows-media-server-or-web-server/

I have created two features one is for Media template another one is media steaming webpart.

Media Template

This is just list definition for storing media files

Media steaming web part

The job of this is to read file from windows media server and play it on windows media player

Steps
First install media features and activate it
Go to Site Actions -> Site Settings-> under Site Administration -> Site libraries and lists -> Create new content - > select Media Library template ->Give the name of template and click create

Just upload media files in to media library the Mediamanager class will take care of rest

Then go to media home page and add media streaming webpart, it will automatically plays media file using streaming technique
Mail me if anybody wants get more knowledge on this.

Tuesday, April 28, 2009

Integrating ASP.NET AJAX in SharePoint

Recently I have done some R&D that is how we can integrate ASP.NET AJAX in SharePoint, here are some steps to make it work

Adding Microsoft ASP.NET AJAX Technology to SharePoint Pages

To implement ASP.NET AJAX in SharePoint you will need to perform few steps.

First, you need to download and install ASP.NET AJAX on all front-end servers.
Second, you need to change web.config with some settings to enable AJAX functionality.
Third, you need to add the ASP.NET AJAX Script Manager control into your master page.

Creating AJAX based Web parts

You can implement AJAX by using Javascript but coordinating between server and client to update only specified parts of a Web page usually requires in-depth knowledge of ECMAScript (JavaScript). However, by using the UpdatePanel control, you can enable a Web page to participate in partial-page updates without writing any client script. When you use an UpdatePanel control, the page behavior is browser independent and can potentially reduce the amount of data that is transferred between client and server.

When you send a request to the server only the particular UpdatPanel region will be sent to server. The entire page will not be refreshed.

The following code is sample code to create AJAX based web part, Here I have taken rating control from AJAX Control Tool Kit.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Threading;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using AjaxControlToolkit;
namespace AjaxRatingControlPart
{
public class AjaxRatingControl : WebPart
{
Rating rating = null;
UpdatePanel upDatePanel = null;
Label lblresult = null;
Button btnSubmit = null;
public AjaxRatingControl()
{
}
protected override void CreateChildControls()
{
btnSubmit = new Button();
btnSubmit.ID = "btnSubmmit"; ;
btnSubmit.Text = "Submit";
btnSubmit.Click += new EventHandler(btnSubmit_Click);
lblresult = new Label();
upDatePanel = new UpdatePanel();
upDatePanel.ID = "UpdatePanel1";
upDatePanel.ChildrenAsTriggers = true;
upDatePanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
this.Controls.Add(upDatePanel);

rating = new Rating();
rating.CurrentRating = 2;
rating.MaxRating = 5;
rating.ID = "testRating";
rating.BehaviorID = "ratingId";
rating.RatingDirection = RatingDirection.RightToLeftBottomToTop;
rating.StarCssClass = "ratingStar";
rating.WaitingStarCssClass = "savedRatingStar";
rating.FilledStarCssClass = "filledRatingStar";
rating.EmptyStarCssClass = "emptyRatingStar";
rating.Changed += new RatingEventHandler(rating_Changed);
upDatePanel.ContentTemplateContainer.Controls.Add(rating);
this.Controls.Add(rating);
this.Controls.Add(lblresult);
this.Controls.Add(btnSubmit);
}

void btnSubmit_Click(object sender, EventArgs e)
{

lblresult.Text = "You have selected " + rating.CurrentRating + "."; ;
//throw new NotImplementedException();
}

void rating_Changed(object sender, RatingEventArgs e)
{
lblresult.Text = "You have selected " + rating.CurrentRating + "."; ;
}
protected override void RenderContents(HtmlTextWriter writer)
{
rating.RenderControl(writer);
upDatePanel.RenderControl(writer);
lblresult.RenderControl(writer);
btnSubmit.RenderControl(writer);
}

}
}


Installing AJAX on front-end servers

If you are using VS2005, You need to download and install <a href="http://www.asp.net/ajax/downloads/">http://www.asp.net/ajax/downloads/</a> from here

If you are using VS2008 no need to download ASP.NET AJAX. By default VS2008 has built in ASP.NET AJAX controls and libraries

Modifying web.config to enable AJAX functionality.

Open web.config under "D:\Inetpub\wwwroot\wss\VirtualDirectories\80" folder
Add <sectiongroup>element within <configsections></configsections>tag:

<sectiongroup type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" name="system.web.extensions">
<sectiongroup type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" name="scripting">
<section type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" name="scriptResourceHandler" requirepermission="false" allowdefinition="MachineToApplication">
<sectiongroup type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" name="webServices">
<section type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" name="jsonSerialization" requirepermission="false" allowdefinition="Everywhere">
<section type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" name="profileService" requirepermission="false" allowdefinition="MachineToApplication">
<section type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" name="authenticationService" requirepermission="false" allowdefinition="MachineToApplication">
<section type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" name="roleService" requirepermission="false" allowdefinition="MachineToApplication">
</sectiongroup>
</sectiongroup>
</sectiongroup>


Add <assemblies>within <assemblies></assemblies>tag:

<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089">
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">

Add <controls>with in <pages>tag:

<controls><add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.UI" tagprefix="asp">
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.UI.WebControls" tagprefix="asp">
</controls>

Add <httphandlers>and <httpmodules>within <system.web>tag:

<httphandlers><remove path="*.asmx" verb="*">
<add type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" path="*.asmx" verb="*" validate="false">
<add type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" path="*_AppService.axd" verb="*" validate="false">
<add type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" path="ScriptResource.axd" verb="GET,HEAD" validate="false">
</httphandlers>
<httpmodules>
<add type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" name="ScriptModule">
</httpmodules>

Add <safecontrol>within <safecontrols>tag:
<safecontrol assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.UI" typename="*" safe="True">

Then save the web.config file and reset IIS

Adding the ASP.NET AJAX Script Manager control into your master page

Open SharePoint Designer

Start -> Programs -> Microsoft Office -> Microsoft Office SharePoint Designer2007-> click on file menu -> Select site url and click on open button

Then expand Master Page Gallery under _catalogs folder -> open default.master page

and register the following assembly <%@ Register Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TagPrefix="asp" %>

Then add the following element with in <form> tag. make sure this should be top level element under <form> tag

<asp:ScriptManager id="scriptmanager1" runat="server" ></asp:ScriptManager> then publish master page and approve it

By using this approach you can integarte ASP.NET AJAX in sharepoint and also you can use AJAXControlToolKit controls in sharepoint2007 i have created AJAX rating control webpart for sharepoint using AJAXControlToolKit

Happy Coding...

Thursday, April 23, 2009

Some good tools to make SharePoint development faster

Some good tools to make SharePoint development faster

WSPBuilder
CAML Builder
SharePoint to Linq

Ted Pattison Group workflow tools

WSPBuilder

By using this tool we can generate SharePoint Solution Package for WSS3.0 and MOSS2007 within seconds

Suppose if we want to develop web part in SharePoint first we have to follow lot of steps like manually creating manifest.xml, feature.xml, creating DDF file and we have to package all these things and deploy as a SharePoint Solution
If you use WSPBuilder no need of doing all these things WSPBuilder will take care creating manifest.xml, feature.xml, creating DDF file and packaging

You can download WSBuilder.exe from CodeFlex site

Steps to create WebPart Using WSPBuilder

Open VS2005/VS2008 and select New Project -> WSPBuilderProject


Step2


Step3

Step4Step5

Step6


See within 6steps we have created and completed SharePoint webpart

Thanks KuetMann for giving this great tool......

CAML Builder(U2UCamlCreator)
CAML queries are good option to retrieve data from SharePoint lists this free tool will help you to create CAML queries very fast and efficient

Step1:


Step2:Step3:By using this you can build your CAML queries veryfast ane efficient

Thanks for U2U

SharePoint to Linq

If you are familiar with LINQ concept then you can use SharePoint to Linq library for querying sharepoint lists

you can query sharepoint lists like this

var result = from t in TravleLists

select t;

Ted Pattison Group workflow tools(WSS3.0)

By using this you can write workflows for WSS3.0 will not support browser enabled Infopath forms so we have to use aspx forms for develpoing workflows

Normally you have to write a lot of code for creating aspx forms in WSS3.0 but this tool will reduce amount of code to develop aspx forms it has built-in forms like association forms, initiation forms,Modification forms etc...

Tuesday, April 21, 2009

SharePoint designer is free

Hello Guys,

NOW SHAREPOINT DESIGNER 2007 IS FREE!

You can download it from Microsoft link

http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=baa3ad86-bfc1-4bd4-9812-d9e710d44f42

Enjoy guys...

Thursday, March 5, 2009

Creating Approved/Rejected Views

Today i had a chat with client , he wanted only Approved documents in document library on webpage. initially i thought it was easy when i tried to create a filter and setting the status field to "Approved". but i did not get any approved documents. I wondered finally i came to know that workflow status is taking numeric values(I think backend enumeration) only.















The values are below


Not Started 0
Failed on Start 1
In Progress 2
Error Occurred 3
Canceled 4
Completed 5
Failed on Start (retrying) 6
Error Occurred (retrying) 7
Canceled 15
Approved 16
Rejected 17