SharePoint Free Training Thursday, Jan 7 2010 

Hi guys I came across this free training for SharePoint 2007 and SharePoint 2010. The training is for both SharePoint developer and SharePoint Administrator. I would like to share this with all my SharePoint friends.

SharePoint Training

Cheers…

SPGridView Problem – Paging and Grouping Tuesday, Dec 8 2009 

Hi guys, i hope u all enjoyed my previous posts. Here i would like to share some information regarding SPGridView in SharePoint. It is one of the most effective and advanced control in SharePoint. Many of them have used this control and they succeed in their part. As per one of the client requirement i have developed a application page with SPGridview and i have added Paging and Grouping. First i add only the paging with custom paging template it works fine. But, when i try to add the Grouping it throws an Unknown Error. I have searched all over the net and i have found the solution. If anyone has encountered this problem please change the EnableViewState property to false and it will work.

Cheers…

Enterprise Search Friday, Sep 5 2008 

Introduction:
Enterprise Search is one of the most compelling features of SharePoint Server 2007. The out-of-the-box capabilities can drastically improve end users’ experience in retrieving relevant information. The same capabilities are available for custom SharePoint applications through dedicated APIs.
There are three ways to create and run search queries against the SharePoint API, each with specific advantages. A description of each approach follows.
  • Keyword Search Queries
  • Search Web Service
  • List Query API (SPQuery Class)

Keyword Search Queries:

This is the most straightforward approach. Once you specify in your code what keywords to look for, you can just run that query and start retrieving results. For its simplicity, the keywords-only approach comes with limitations. In particular you will not be able to define comparison constraints in the query.

Search Web Service:

SharePoint Server 2007 exposes most of its search functionalities as a web service. You can reference this web service from any other application to run queries against your SharePoint farm and use those results outside the context of SharePoint Server. Because all our code executes in the context of SharePoint Server, we passed on leveraging the search web service to favor full text SQL queries.

List query API (SPQuery class):

SPQuery is the class of choice to query and return items from a single SharePoint list. The query syntax uses CAML (Collaborative Application Markup Language). CAML queries were already available in SharePoint Server 2003. They provide a way to run XML-formatted queries against SharePoint content. The syntax is quite powerful, with the ability to filter data based on field comparisons. Note that by default only queried items in a single list folder will be returned. Items from subfolders will not be included in the search results.

Cheers…

To create a minimal master page Monday, Sep 1 2008 

  • Open SharePoint Designer.
  • On the File menu, click New, point to SharePoint Content, and then click the Page tab.
  • Double-click Master Page to create a new master page.
  • Click Design to show the master page in design view. You should see header and left margin areas and several content placeholders in the master page.
  • Click Code to show the master page in code view.
  • Copy the Code into the Master Page.
  • On the File menu, click Save As, provide a unique file name with the .master extension, and then save the file to the master page gallery (/_catalogs/masterpage) in your site collection.

Cheers…

How to: Create a Minimal Master Page Monday, Sep 1 2008 

Introduction
One of the first tasks that you must complete when configuring a Microsoft Office SharePoint Server 2007 Web site is to create one or more master pages. A master page contains references to elements that you can share across multiple pages in an Office SharePoint Server 2007 site, such as navigation, search controls, logon controls, and banner images. A master page can also contain the cascading style sheet (CSS) and ECMAScript (JScript, JavaScript) references that define the overall look and feel of your site. Commonly, every site—and therefore every page—in your site collection uses the same master page to present a consistent user experience across the entire site collection. Depending on your needs, you can use a different master page for one or for all of the sites in your site hierarchy to distinguish the various areas of your portal.
Master Page Galleries
When you provision a site collection in Office SharePoint Server 2007, the system creates a master page gallery that contains all the master pages and page layouts for that site collection. If the site collection uses either the Publishing Portal or Collaboration Portal templates, the master page gallery includes several master pages that are provided with Office SharePoint Server 2007, such as BlueBand.master. These master pages are located in the path C:\Program%20Files\Common%20Files\Microsoft%20Shared\web%20server%20extensions\12\TEMPLATE\FEATURES\PublishingLayouts\MasterPages\, with other example .master pages. You can use any of these master pages as they are, or you can customize them fully to create unique branding for your site.
Why Start with a Minimal Master Page
Creating and completing a master page to begin your SharePoint site customization takes planning and time. If you can, you want to prevent having to rewrite or back out code you don’t need in your master page. This topic shows you how to create a minimal master page that includes only the minimal functionality that Office SharePoint Server 2007 requires so that you have a stable platform upon which to build your own master pages. Creating a minimal master page can help you avoid the time-consuming process of backing code out of a pre-existing .master page such as BlueBand.master, or removing functionality and then building it back in when your customization needs change again.
You can, of course, create a master page from scratch. However, we generally do not recommend this because a truly empty master page does not include all the content placeholders that the Office SharePoint Server 2007 page model needs to work correctly.
The sample code in the following procedure includes only what the Office SharePoint Server 2007 page model requires—necessary content placeholders and controls to work with the page layouts that are included in a default Office SharePoint Server 2007 installation. Office SharePoint Server 2007 requires a master page that includes a title, branding, logon functionality, search functionality, breadcrumb functionality, and basic structural elements such as page areas, separators, borders, consoles, and description placeholders.
The following procedure uses Office SharePoint Designer 2007 as the master page design environment. You can, however, use a text editor, a Web editor such as Microsoft Office SharePoint Designer 2007, or an integrated development environment (IDE) such as Microsoft Visual Studio 2005 to create a master page.The master pages included with Office SharePoint Server 2007 are based on the SPWeb.CustomMasterUrl property of the SPWeb class in Windows SharePoint Services.
Cheers…

How to:Extend the Navigation Provider Saturday, Aug 30 2008 

You can extend the navigation provider in Microsoft Office SharePoint Server 2007 by deriving a custom provider class from any of the default site map providers. Deriving from an Office SharePoint Server 2007 site map provider supplies several benefits such as navigation node caching and security trimming. The following code example derives from the PortalSiteMapProvider class and demonstrates how to add items to the site map provider. Although the site map provider classes have approximately twenty abstract or virtual methods, only a small number must be overridden and implemented in a custom site map provider.
  • Create a Microsoft Visual C# class library project with following code, add the required references, and then build the project.

using System;using System.Collections.Generic;using System.Text;using Microsoft.SharePoint.Publishing;using Microsoft.SharePoint.Publishing.Navigation;using System.Web;using System.Web.UI.WebControls;using System.Configuration;

namespace MyCustomNav

{

public class Navigation: PortalSiteMapProvider

{

public override SiteMapNodeCollection

GetChildNodes(System.Web.SiteMapNode node)

{PortalSiteMapNode pNode = node as PortalSiteMapNode;

if (pNode != null)

{if (pNode.Type == NodeTypes.Area)

{SiteMapNodeCollection nodeColl = base.GetChildNodes(pNode);

SiteMapNode childNode = new

SiteMapNode(this, “”,

“”, “Microsoft”);

SiteMapNode childNode1 = new

SiteMapNode(this, “”,

“”,

“Support”);nodeColl.Add(childNode);

SiteMapNodeCollection test = new

SiteMapNodeCollection();test.Add(childNode1);

childNode.ChildNodes = test;return nodeColl;

}elsereturn base.GetChildNodes(pNode);

}elsereturn new SiteMapNodeCollection();

}}}

  • Copy the .dll file you created in step 1, and then paste it into the Office SharePoint Server 2007 virtual directory’s bin folder.
  • Create the following entry in the web.config file for the Web application, and then set the trust level to Full.

<add name=”MyCustomNavigationProvider” type=”MyCustomNav.Navigation, MyCustomNav”
NavigationType=”Current”/>

  • Create a custom master page and add the following code under the top navigation’s ContentPlaceHolder element.

<sharepoint:aspmenuid=”topnavigationmenu” runat=”server” datasourceid=”topSiteMap1″ enableviewstate=”false” accesskey=””>” Orientation=”Horizontal” StaticDisplayLevels=”1″ MaximumDynamicDisplayLevels=”3″ DynamicHorizontalOffset=”0″ StaticPopoutImageUrl=”/_layouts/images/menudark.gif” StaticPopoutImageTextFormatString=”” DynamicHoverStyle-BackColor=”#CBE3F0″ SkipLinkText=”” StaticSubMenuIndent=”0″ CssClass=”ms-topNavContainer”>

<staticmenustyle/><staticmenuitemstyle cssclass=”ms-topnav” itemspacing=”0px”/><staticselectedstyle cssclass=”ms-topnavselected”/><statichoverstyle cssclass=”ms-topNavHover”/><dynamicmenustyle backcolor=”#F2F3F4″ bordercolor=”#A7B4CE” borderwidth=”1px”/><dynamicmenuitemstyle cssclass=”ms-topNavFlyOuts”>/><dynamicselectedstyle cssclass=”ms-topNavFlyOutsSelected”/></SharePoint:AspMenu>

<asp:sitemapdatasource showstartingnode=”False” sitemapprovider=”MyCustomNavigationProvider” id=”topSiteMap1″ runat=”server” startfromcurrentnode=”true”>

  • Reset Microsoft Internet Information Server (IIS). Your SharePoint site should now show the updated navigation from the extended navigation provider.

Still more to come…

Cheers…


Customizing Navigation Controls and Providers Sunday, Aug 17 2008 

To customize navigation, you should rely on the ASP.NET Site Navigation mechanism, because it provides a standard, consistent, and easily managed solution.
Customizing Web Display Controls (Menu, TreeView, and SiteMapPath) :
You can customize the look and feel of standard display controls by using cascading style sheets (CSSs). You can also write your own ASP.NET 2.0 controls and use them in Office SharePoint Server 2007 navigation. To learn more, see the Menu class documentation.

Note: Office SharePoint Server 2007 also provides default navigation components that you can customize, such as the Content By Query Web Part and the Table of Contents Web Part. You can configure these two controls to present a custom selection of links.

To implement your own site map provider, you can derive a custom provider class from any of the default site map providers. Office SharePoint Server 2007 includes several default providers. You can also derive a custom provider class from the SiteMapProvider class in the System.Web namespace. However, deriving the Office SharePoint Server 2007 site map providers supplies several additional benefits such as navigation node caching and security trimming. Therefore, you should use the Office SharePoint Server 2007 caching and security trimming infrastructure instead of writing your own caching and security trimming in a custom provider by deriving from the default providers. Although the site map provider classes have approximately twenty abstract or virtual methods, only a small number must be overridden and implemented in a custom site map provider. The following code example derives from the PortalSiteMapProvider class and demonstrates how to add items to the site map provider.

public class CustomNavProviderWithList : PortalSiteMapProvider {
public override SiteMapNodeCollection

GetChildNodes(System.Web.SiteMapNode node) {
PortalSiteMapNode portalNode = node as PortalSiteMapNode;
if (portalNode != null)
{
if (portalNode.Type == NodeTypes.Area)
{ SiteMapNodeCollection nodeColl = base.GetChildNodes(portalNode);
using (SPSite currentSite = new SPSite(portalNode.Url))
{ SPWeb currentWeb = currentSite.OpenWeb();
SPListCollection lists = currentWeb.Lists;
foreach (SPList list in lists)
{ string listUrl = list.DefaultViewUrl;
PortalSiteMapNode childNode =
new PortalSiteMapNode(webNode,
listUrl, NodeTypes.custom, list.Title, listUrl, null);
nodeColl.Add(childNode);
} }
return nodeColl;
} else { return base.GetChildNodes(portalNode);
} }
else { return new SiteMapNodeCollection(); } } }

Cheers…

PortalSiteMapProvider Saturday, Aug 16 2008 

The PortalSiteMapProvider object is the true source of hierarchical navigation data and it provides the data to the PortalSiteMapDataSource object. The PortalSiteMapProvider retrieves nodes from the Windows SharePoint Services 3.0 SPNavigation store. You use the SPNavigation object to create static links and groupings. After you provide static links and groupings, the application merges in dynamic items that represent Web sites and pages with the static links and groupings. Office SharePoint Server 2007 also applies security trimming so that users see only the navigation items to which they have permission to navigate.
Declare named providers in the application’s web.config file to make them widely accessible. Declarations of the two most important PortalSiteMapProvider objects—
CombinedNavSiteMapProvider and CurrentSiteNavSiteMapProvider—are shown in the following code.

<add name=”CombinedNavSiteMapProvider” description=

“MOSS 2007 provider for Combined navigation” Type=”Microsoft.SharePoint.Publishing.
Navigation.PortalSiteMapProvider”
NavigationType=”Combined” EncodeOutput=”true”>
<add name=”CurrentNavSiteMapProvider” description=
“MOSS 2007 provider for Current navigation” Type=
“Microsoft.SharePoint.Publishing.
Navigation.PortalSiteMapProvider”
NavigationType=”Current” EncodeOutput=”true”/>
Note : The name of the first provider, CombinedNavSiteMapProvider, matches the value specified for the SiteMapProvider property. This indicates that a Horizontal menu will be created.
The following are the properties,
  1. NavigationType – Gets or sets the type of navigation for this navigation provider. Available options include “Combined”, “Current”, and “Global” and behave as specified by the next three properties: CombinedNavSiteMapProvider, CurrentSiteMapProvider, and CurrentSiteNavSiteMapProviderNoEncode.
  2. CombinedNavSiteMapProvider – Gets the PortalSiteMapProvider object that is attached by default to the global navigation menu.
  3. CurrentSiteNavSiteMapProvider – Gets the PortalSiteMapProvider object that is attached by default to the current navigation menu or the QuickLaunch toolbar.
  4. CurrentSiteNavSiteMapProviderNoEncode – Gets the PortalSiteMapProvider object that is attached by default to the breadcrumb navigation.
    Declare this property almost identically to CurrentSiteNavSiteMapProvider, but exclude the EncodeOutput=”true” attribute.
  5. GlobalNavSiteMapProvider – Gets a PortalSiteMapProvider object with the NavigationType property set to Global.
  6. EncodeOutput – Gets or sets whether to HTML-encode the Title property of any PortalSiteMapNode object returned by the provider.The ASP.NET 2.0 menu control does not automatically HTML-encode the Title property when rendering. However, the ASP.NET 2.0 SiteMapPath control does HTML-encode the Title property.
  7. DynamicChildLimit – Gets or sets the number of dynamic child items to show at each level. Dynamic child items can be subsites (any SPWeb objects) and pages.
  8. RequireUniqueKeysForNodes – Gets or sets whether nodes returned from the provider should each have unique values for their Key properties.
    To enable menu highlighting to work correctly on authored links and headings, set RequireUniqueKeysForNodes=”false”. This does not cause problems when attaching to an ASP.NET 2.0 menu control through a data source, but for most other display controls, declare RequireUniqueKeysForNodes=”true”.
  9. IncludeSubSites – Gets or sets whether this provider returns subsites.

Cheers…

PortalSiteMapDataSource Saturday, Aug 16 2008 

The PortalSiteMapDataSource is a data source specific to Office SharePoint Server 2007 that retrieves data from the PortalSiteMapProvider object and exposes data according to the ASP.NET 2.0 hierarchical data source interface. The PortalSiteMapDataSource object specifies the name of the PortalSiteMapProvider object it uses to retrieve data through the ASP.NET 2.0 SiteMapProvider property.
When the master page markup includes the DataSourceID=”GlobalNavDataSource” attribute, the application returns a PortalSiteMapDataSource object.

<PublishingNavigation:PortalSiteMapDataSource ID=”GlobalNavDataSource” Runat=”server” SiteMapProvider=”CombinedNavSiteMapProvider” ShowStartingNode=”false” StartFromCurrentNode=”true” StartingNodeOffset=”0″ TrimNonCurrentTypes=”Heading” TreatStartingNodeAsCurrent=”true”/>

The properties are,

  1. ShowStartingNode – Affects whether the starting node is returned by the data source.When this property is set to true, the data source returns the starting node. The menu receives the starting node, which can be the root node, and items below the starting node.When this property is set to false, the data source does not return the starting node. The menu receives only the items below the starting node.
  2. StartFromCurrentNode – Affects where the data source starts. That is, this property sets which section of the overall site hierarchy the data source control returns to the menu.When this property is set to true, Office SharePoint Server 2007 instructs the PortalSiteMapDataSource object to apply its rules for determining where it should be starting.
  3. StartingNodeOffset – Gets or sets a positive or negative integer offset from the starting node that determines the top-level site hierarchy that is exposed by the DataSourceControl object.The default is 0, which indicates that the top-level site hierarchy exposed by the SiteMapDataSource object is the same as the starting node.The effect of this property is variable, undefined, and depends on site hierarchy details that are out of scope for this topic.
  4. TrimNonCurrentTypes – Allows context-based and type-based node trimming.
    In this example, TrimNonCurrentTypes=”Heading”, which instructs the data source to remove any nodes of type Heading that are not directly below the current node.
    You can specify multiple values for this property in a comma-delimited list. Available values are defined in the
    NodeTypes enumeration.
  5. TrimNonAncestorTypes – Trims any specified types that are not directly below the current site or one of its ancestors.
  6. TrimNonAncestorDescendantTypes – Trims any nodes of specified types that are not below the current site or one of its ancestor or descendant sites.
  7. TreatStartingNodeAsCurrent – Affects which node is treated as the current node for trimming purposes. By default, current node refers to the node representing the item that is currently being visited.When TreatStartingNodeAsCurrent is set to true, the starting node of the data source is treated as the context or trimming node.

Cheers…

Horizontal and Vertical Menus Saturday, Aug 16 2008 

When you first create a site structure that includes a root or top-level site, more than one Web site, and pages and additional sites that are children of the top-level site, Office SharePoint Server 2007 creates two menus: a horizontal (top) menu, and a vertical (left) menu.
Horizontal and vertical menus are declared in master page markup. The following example declares a horizontal menu.

<SharePoint:AspMenu ID=”GlobalNav” Runat=”server” DataSourceID=”GlobalNavDataSource” Orientation=”Horizontal” StaticDisplayLevels=”1″ MaximumDynamicDisplayLevels=”1″/>

The vertical menu is declared similarly, but uses different properties from the horizontal menu. These properties are identical to those available on the ASP.NET 2.0 Menu control.

The following are the properties included by default in master page markup for both horizontal and vertical menus:

  1. DataSourceID – Specifies the data source control that provides the hierarchical data for this menu. In the previous example code, the DataSourceID points to a control with the ID “GlobalNavDataSource”.
  2. Orientation – Specifies whether the menu is horizontal or vertical.
  3. StaticDisplayLevels – Specifies the number of hierarchy levels to show in the menu at the same time.
  4. MaximumDynamicDisplayLevels – Specifies the number of levels to show in dynamic fly-out menus.

Cheers…

Next Page »