Thursday, April 30, 2009

Download SharePoint Service Pack 2

Service pack 2 is available for MOSS 2007 & WSS,

Windows SharePoint Services

Office SharePoint Server 2007


Read more...

Monday, April 27, 2009

Using the Ajax Control Toolkit Rating Control in SharePoint - a real-life example

As I had a hard time finding a working example of how the Ajax Control Toolkit Rating control has been implemented in SharePoin, I'm providing you here with a working example that you can download an use as a template.

It is fairly easy to implement this Ajax control in SharePoint, just make sure that you've update your web.config in order to support .NET 3.5 and AJAX controls. A good example can be found here.


My example provides the following functionalities:

  • Shows the current rating the user has given earlier.
  • Allows the user to set/change the rating.
  • After rating, it shows an additional textbox that allows the user to leave an optional comment.

In my project, we had as well another rating control (in read-only mode) that shows the aggregation of all ratings given for that page. This rating control has been implemented using exactly the same "pattern" as shown in the code, only with an additional line

_racOverallRating.ReadOnly = true;

and obviously a different data source.

Please be aware that the source code is of an exemplary nature as I have deleted and commented all parts that are going to the business logic layer. But it should allow you to easily implement the rating control and enhance your SharePoint!

Any questions, just let me know.

Article was published on www.sharepointblogs.com by

Read more...

WebParts and Audiences - Part 2: Create a custom ToolPart/EditorPart to configure audiences for your custom WebPart

This is part 2 of a series I will write on how to deal with audiences in your custom SharePoint WebParts.

In this post, I will show you how to create a custom ToolPart/EditorPart for your WebPart that allows to configure audience settings for the WebPart. In my example I've implemented to possible settings:

  • Audience targeting for the whole WebPart (if a user is not in the right audience the WebPart will be invisible --> see Part 1)
  • Audience targeting for the data items that are showed in the WebPart (see in a later part of the series).

In order to allow the user to pick the audiences, I am using the standard-SharePoint AudienceEditor web control:

_wpAudiences.Types = AudienceEditor.AudienceType.DL | AudienceEditor.AudienceType.GlobalAudience | AudienceEditor.AudienceType.SharePointGroup;
_wpAudiences.Visible = true;
_wpAudiences.Width = Unit.Pixel(0x182);
this.AddConfigurationOption("WebPart Audiences", "Members of these audiences can view the Web Part. If left blank, everyone can see the Web Part",
_wpAudiences);

here is full implementation:

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using Microsoft.SharePoint.WebPartPages;

namespace YourNameSpace
{

/// Base class for all custom ToolParts.

public class BaseToolPart : ToolPart, INamingContainer
{

#region Overridden Members


/// Called if a user has commited a configuration change.

public override void ApplyChanges()
{
this.OnAppliedChanges(EventArgs.Empty);
base.ApplyChanges();
}

#endregion

#region Protected Members
/// Creates a label and a corresponding control.



///
protected virtual void AddConfigurationOption(string title, Control inputControl)
{
this.AddConfigurationOption(title, null, inputControl);
}

///
/// Creates a label and a corresponding control.

protected virtual void AddConfigurationOption(string title, string description, Control inputControl)
{
this.AddConfigurationOption(title, description, new List(new Control[]{inputControl}));
}

///
/// Creates a label and a corresponding control.

protected virtual void AddConfigurationOption(string title, string description, IEnumerable inputControls)
{
HtmlGenericControl divSectionHead = new HtmlGenericControl("div");
divSectionHead.Attributes.Add("class", "UserSectionHead");
this.Controls.Add(divSectionHead);

HtmlGenericControl labTitle = new HtmlGenericControl("label");
labTitle.InnerHtml = HttpUtility.HtmlEncode(title);
divSectionHead.Controls.Add(labTitle);

HtmlGenericControl divUserSectionBody = new HtmlGenericControl("div");
divUserSectionBody.Attributes.Add("class", "UserSectionBody");
this.Controls.Add(divUserSectionBody);

HtmlGenericControl divUserControlGroup = new HtmlGenericControl("div");
divUserControlGroup.Attributes.Add("class", "UserControlGroup");
divUserSectionBody.Controls.Add(divUserControlGroup);

if (!string.IsNullOrEmpty(description))
{
HtmlGenericControl spnDescription= new HtmlGenericControl("div");
spnDescription.InnerHtml = HttpUtility.HtmlEncode(description);
divUserControlGroup.Controls.Add(spnDescription);
}

foreach (Control inputControl in inputControls)
{
divUserControlGroup.Controls.Add(inputControl);
}

HtmlGenericControl divUserDottedLine = new HtmlGenericControl("div");
divUserDottedLine.Attributes.Add("class", "UserDottedLine");
divUserDottedLine.Style.Add(HtmlTextWriterStyle.Width, "100%");
this.Controls.Add(divUserDottedLine);
}

#endregion

#region Events & Handlers
///
/// Fires after a user has commited a configuration change.
///
public event EventHandler AppliedChanges;

///
/// Called after a user has commited a configuration change (ApplyChanges).
///
protected virtual void OnAppliedChanges(EventArgs e)
{
if (this.AppliedChanges != null)
this.AppliedChanges(this, e);
}

#endregion
}
}

-----------------------------------------------------------

using System.Web.UI.WebControls;
using Microsoft.Office.Server.WebControls;

namespace YourNameSpace
{
public class AudiencesToolPart : BaseToolPart
{

#region Constants and Private Members
private AudienceEditor _wpAudiences = new AudienceEditor();
private CheckBox _chkFilterContentByAudience = new CheckBox();
private bool _showWebPartAudiences = true;
private bool _showFilterContentByAudiences = true;

#endregion

public AudiencesToolPart()
{
this.Title = "Audiences";
}

#endregion

#region Overridden members

protected override void CreateChildControls()
{
if (_showWebPartAudiences)
{
_wpAudiences.Types = AudienceEditor.AudienceType.DL | AudienceEditor.AudienceType.GlobalAudience | AudienceEditor.AudienceType.SharePointGroup;
_wpAudiences.Visible = true;
_wpAudiences.Width = Unit.Pixel(0x182);
this.AddConfigurationOption("WebPart Audiences", "Members of these audiences can view the Web Part. If left blank, everyone can see the Web Part",
_wpAudiences);
}

if (_showFilterContentByAudiences)
{
this._chkFilterContentByAudience.ID = "chkContentFiltering";
this.AddConfigurationOption("Content filtering", "If checked, audience-filtering will be applied to the contents of this Web Part",
this._chkFilterContentByAudience);
}

base.CreateChildControls();
}


#endregion

#region Public Members

public bool FilterContentByAudience
{
get
{
return this._chkFilterContentByAudience.Checked;
}
set
{
this._chkFilterContentByAudience.Checked = value;
}
}

public string WebPartAudiences
{
get
{
return this._wpAudiences.Text;
}
set
{
this._wpAudiences.Text = value;
}
}


public bool ShowWebPartAudiences
{
get { return this._showWebPartAudiences; }
set { this._showWebPartAudiences = value; }
}

public bool ShowFilterContentByAudiences
{
get { return this._showFilterContentByAudiences; }
set { this._showFilterContentByAudiences = value; }
}
#endregion

}
}







Read more...

WebParts and Audiences - Part 1: Show or hide a Web Part based on audiences

This is part 1 of a series I will write on how to deal with audiences in your custom SharePoint WebParts.

Some of the standard SharePoint WebParts implement audience filtering. I was wondering, what it takes to make my custom WebParts as well audience "sensitive". I wanted to apply the audience filtering at 2 different levels:

  • Show or hide the WebPart depending on audiences
  • Show or hide data items the WebPart displays depending on audiences.

As well, I wanted to enable administrators / power users to configure the WebPart to filter for audiences, which meant to create a custom ToolPart/EditorPart.

In this first part of the series, we will look at how hide a custom WebPart if the user is not in one of the necessary audiences that are allowed to see the WebPart.

In order to store the audiences that are allowed to see the WebPart, we must create a shared-property that will be configured using our custom ToolPart/EditorPart which I will describe in Part 2 of my series.

[WebBrowsable(false), FriendlyName("WebPart target audiences"), Description(""),
Category("Presentation"), DefaultValue(""), WebPartStorage(Storage.Shared), Personalizable(PersonalizationScope.Shared)]
public string TargetAudiences
{
get
{
return this._targetAudiences;
}
set
{
this._targetAudiences = value;
}
}

This property stores the value given back by the standard-SharePoint AudienceEditor control Text-property as I will describe in part 2. Given this WebPart-property, all we need to do is to override the OnPreRender-method of our WebPart with the following:

protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);

this.Hidden = false;

if (!string.IsNullOrEmpty(TargetAudiences))
{
if (ServerContext.Current == null)
return;

AudienceLoader audienceLoader = AudienceLoader.GetAudienceLoader();
if (!AudienceManager.IsCurrentUserInAudienceOf(audienceLoader, this.TargetAudiences, false))
{
this.Hidden = true;
}
}
}

Try it :) If the current user is not in one of the audiences that are configured for your WebPart - the whole WebPart will be hidden.

Read more...

Saturday, April 25, 2009

Adding WebParts programmatically to a WebPartZone

I had a very hard time finding information on the web on how to correctly add Web Parts programmatically to my SharePoint WebPartZone.

It's easy to get all the WebParts that are present in the current Site:

SPContext.Current.Site.GetCatalog(SPListTemplateType.WebPartCatalog

Since this is a normal SharePoint list it is also easy to extract the items, display them etc... Now, given that I have selected the WebPart that I want to add:

SPListItem selectedWebPartListItem = SPContext.Current.Site.GetCatalog(SPListTemplateType.WebPartCatalog).Items.GetItemById(selectedWebPartId);

I need now an instance of SPLimitedWebPartManager (Make sure you take the correct PersonalizationScope):

using (SPLimitedWebPartManager manager = SPContext.Current.Web.GetLimitedWebPartManager(this.Page.Request.Url.ToString(), PersonalizationScope.Shared))
{ ... code ... }

Now my trouble started... I found code to create an instance of the WebPart:

string typeName = selectedWebPartListItem.GetFormattedValue("WebPartTypeName");
string assemblyName = selectedWebPartListItem.GetFormattedValue("WebPartAssembly");
ObjectHandle webPartHandle = Activator.CreateInstance(assemblyName, typeName);
System.Web.UI.WebControls.WebParts.WebPart webPart = (System.Web.UI.WebControls.WebParts.WebPart)webPartHandle.Unwrap();

This looks nice - but is completely the WRONG thing to do!

If you are creating an instance of the WebPart like this, you are completely ignoring the (maybe) individual configuration that is set in the .webpart or .dwp file!

The right and (at least in my environment) working way is to import the WebPart like this:

string fileName = string.Format("{0}/{1}", selectedWebPartListItem.Web.Url, selectedWebPartListItem.File.Url);
XmlUrlResolver xmlResolver = new XmlUrlResolver();
xmlResolver.Credentials = CredentialCache.DefaultCredentials;
XmlTextReader reader = new XmlTextReader(fileName);

string errorMsg;
System.Web.UI.WebControls.WebParts.WebPart webPart = manager.ImportWebPart(reader, out errorMsg);

if (!string.IsNullOrEmpty(errorMsg)) {
// your exception handling goes here
}
else
{
manager.AddWebPart(webPart, _wpManager.Zones[_ddlWebPartZones.SelectedItem.Value].ID, Convert.ToInt32(rowIndex));
}


Read more...

Friday, April 24, 2009

Tips & Tricks: Microsoft Enterprise Library Configuration

In my projects, I’m using more and more the Microsoft Enterprise Library Logging Application Block as it provides us with an extensible Logging-Framework that is easy to adjust. Even to write to the ULS Log, a simple ULSLogTraceListener can be implemented by inheriting from CustomTraceListener.

However, I found that there are certain tips & tricks worth knowing when developing projects using the Enterprise Library Application Blocks when it comes to configuration:

Configure Visual Studio:

If you want to show any components in design view that are using an Enterprise Application Block, you need to modify the configuration file of the Visual Studio Development Environment application. Otherwise, you will get errors such as “The configuration section for Logging cannot be found in the configuration source.”.

Here is an example for Visual Studio 2008. Go to :\Program Files\Microsoft Visual Studio 9.0\Common7\IDE and locate the file devenv.exe.config.

You need now to add a configuration section for each application block you are using. Here is my example for the logging application block, with an empty configuration:

Configure (Unit) Test projects

Even though the (web) application you are testing has a valid configuration, projects using them for testing or other purposes must have as well a valid configuration, as they are considered the “application”. So if you run into any errors in these projects – make sure you have a configuration file for them!


Article published on :http://www.sharepointblogs.com by

Read more...

Monday, April 20, 2009

Possible Issue with mergecontentdb STSADM Operation

Under certain circumstances, the mergecontentdb Stsadm operation may fail. These circumstances include combinations of significant site collection size, user traffic, and SQL Server load. When the command fails, both the source and destination databases can be corrupted.

If you use mergecontentdb, make sure that you:

· Always back up both the source and target databases before using this operation.

· Refrain from cancelling the operation (either on the front-end Web server or the server running SQL Server).

· Run the command during off-peak hours, because mergecontentdb places significant additional load on the server running SQL Server.

Alternatively, consider using Batch Site Manager and the method described here. Because the Batch Site Manager works with site collections by using the Stsadm backup and restore operations with the –url parameter, we recommend that you not use Batch Site Manager for site collections larger than 15 GB.

The Batch Site Manager is included in the SharePoint Administration Toolkit:

· Microsoft SharePoint Administration Toolkit v3.0 x86

· Microsoft SharePoint Administration Toolkit v3.0 x64

Related KB:

http://support.microsoft.com/kb/969242

A fix is about to be released in the coming months to address this issue, we will update once it becomes available.

Read more...

Hide the Sign In link for the anonymous access user in anonymous access enabled site - Bend the Welcome.ascx - SharePoint MOSS

Lots of thing can be done by playing around the Welcome.ascx user control. I have came across one of the interesting thing on hiding the “Sign In” link for anonymous access users in the public facing internet site and thought of sharing with you.

 

Following are the two steps to implement this requirement in the supported way and its quite easy, thanks to master page and the SharePoint Application Page link control.

 

1.    Create a custom user control based on the OOB “WelCome.ascx” control. Override the “OnLoad” event and hide the “Sign In” application page link for the anonymous access user.

 

2.    Create a custom master page based on the any OOB parent master page with respect to your requirement and site definition. Render the Custom welcome control in the place of OOB welcome control.

 

 

You can find the Welcome.ascx user control under the “Control Templates” folder. Bunch of menu items are available for the authenticated user like My Settings, Sign in as different user, Log Out and Personalize the page. All these menu items are available as feature menu template and will be available only if the user was authenticated successfully. Following is the structure of the feature menu template and all the menu items are available under the ID “ExplicitLogOut”. You can see that the visibility of this Personal Actions control is false and the visibility will be made to true when the user is successfully authenticated.

 <SharePoint:PersonalActions AccessKey="<%$Resources:wss,personalactions_menu_ak%>"ToolTip="<%$Resources:wss,open_menu%>" runat="server" id="ExplicitLogout" Visible="false">

      <CustomTemplate>

       <SharePoint:FeatureMenuTemplate runat="server"

             FeatureScope="Site"

             Location="Microsoft.SharePoint.StandardMenu"

             GroupId="PersonalActions"

             id="ID_PersonalActionMenu"

             UseShortId="true"

             >

             <SharePoint:MenuItemTemplate runat="server" id="ID_PersonalInformation"

                         Text="<%$Resources:wss,personalactions_personalinformation%>"

                         Description="<%$Resources:wss,personalactions_personalinformationdescription%>"

                         MenuGroupId="100"

                         Sequence="100"

                         ImageUrl="/_layouts/images/menuprofile.gif"

                         UseShortId="true"

                         />

             <SharePoint:MenuItemTemplate runat="server" id="ID_LoginAsDifferentUser"

                         Text="<%$Resources:wss,personalactions_loginasdifferentuser%>"

                         Description="<%$Resources:wss,personalactions_loginasdifferentuserdescription%>"

                         MenuGroupId="200"

                         Sequence="100"

                         UseShortId="true"

                         />

             <SharePoint:MenuItemTemplate runat="server" id="ID_RequestAccess"

                         Text="<%$Resources:wss,personalactions_requestaccess%>"

                         Description="<%$Resources:wss,personalactions_requestaccessdescription%>"

                         MenuGroupId="200"

                         UseShortId="true"

                         Sequence="200"

                         />

             <SharePoint:MenuItemTemplate runat="server" id="ID_Logout"

                         Text="<%$Resources:wss,personalactions_logout%>"

                         Description="<%$Resources:wss,personalactions_logoutdescription%>"

                         MenuGroupId="200"

                         Sequence="300"

                         UseShortId="true"

                         />

             <SharePoint:MenuItemTemplate runat="server" id="ID_PersonalizePage"

                         Text="<%$Resources:wss,personalactions_personalizepage%>"

                         Description="<%$Resources:wss,personalactions_personalizepagedescription%>"

                         ImageUrl="/_layouts/images/menupersonalize.gif"

                         ClientOnClickScript="javascript:MSOLayout_ChangeLayoutMode(true);"

                         PermissionsString="AddDelPrivateWebParts,UpdatePersonalWebParts"

                         PermissionMode="Any"

                         MenuGroupId="300"

                         Sequence="100"

                         UseShortId="true"

                         />

             <SharePoint:MenuItemTemplate runat="server" id="ID_SwitchView"

                         MenuGroupId="300"

                         Sequence="200"

                         UseShortId="true"

                         />

             <SharePoint:MenuItemTemplate runat="server" id="MSOMenu_RestoreDefaults"

                         Text="<%$Resources:wss,personalactions_restorepagedefaults%>"

                         Description="<%$Resources:wss,personalactions_restorepagedefaultsdescription%>"

                         ClientOnClickNavigateUrl="javascript:MSOWebPartPage_RestorePageDefault()"

                         MenuGroupId="300"

                         Sequence="300"

                         UseShortId="true"

                         />

       SharePoint:FeatureMenuTemplate>

      CustomTemplate>

SharePoint:PersonalActions>

 

 

The another part of the welcome user control is “ExplicitLogin” which has been rendered as the SharePoint Application Page Link as follows.

 

<SharePoint:ApplicationPageLink runat="server" id="ExplicitLogin"

      ApplicationPageFileName="Authenticate.aspx" AppendCurrentPageUrl=true

      Text="<%$Resources:wss,login_pagetitle%>" style="display:none" Visible="false" />

 

 

This is the link which we need to concentrate for this requirement. By default this link visibility is false and will come alive when the user is not authenticated. This is what happens with the anonymous access user. When the anonymous user access the site this link is visible so that the unauthenticated user can sign in.

 

Fair enough on the post mortem of the welcome user control. Now copy this welcome user control and paste it under the Control templates folder as “CustomWelcome.ascx” control. In the “CustomWelcome.ascx” control add an In Line script and override the “OnLoad” event. In the “OnLoad” event for the unauthenticated user hide the  “ExplicitLogin” link.

 

protected override void OnLoad(EventArgs e)

    {

        //base.OnLoad(e);

        base.OnLoad(e);

        if (HttpContext.Current.User.Identity.IsAuthenticated)

        {

            this.ExplicitLogout.Visible = true;

        }

        else

        {

            this.ExplicitLogin.Visible = false;

            this.ExplicitLogin.Attributes.CssStyle.Add("display""block");

        }

 

    }

 

Now we are done with the custom welcome user control. Let us have a look on rendering it through the custom master page based on the “default.master” master page. Copy the default.master page and add the Tag prefix reference for the “CustomWelcom.ascx” control as follows in the custom master page :

 

<%@ Register TagPrefix="wssuc" TagName="CustomWelcome" src="~/_controltemplates/CustomWelcome.ascx" %>

 

Find the following entry in the master page :

 

<wssuc:Welcome id="IdWelcome" runat="server" EnableViewState="false">

                  wssuc:Welcome>

 

Replace the above entry with the following entry to replace the OOB welcome user control with your custom welcome user control :

 

<wssuc:CustomWelcome id="IdWelcome" runat="server" EnableViewState="false">

                  wssuc:Welcome>

 

Save the custom master page and use it for the public facing internet site and now “Sign In” link will not be available for the unauthenticated anonymous access user.

 

If you are aware of the whole welcome.ascx control and its structure then you can play with it for bending its behavior through custom user control. Happy customizing J

Read more...

Sunday, April 12, 2009

The Six most Innovative feature of MOSS 2007

The Six most Innovative feature of MOSS 2007

1. Collaboration
By integrating Workspaces, Tasks, Forums, Surveys, Blogs, RSS and Wikis, the platform builds on the wild success of the 2003 collaboration features while hitting the Web 2.0 check box items for the new wave of collaboration and knowledge management applications. Point players in this space — SocialText, BlogTronix, SuiteTwo, eTouch, BaseCamp, Automattic, etc. — will no doubt out perform in select areas, on a feature by feature comparison, but previous adoption rates, customizability, and convenience will carry MOSS a long way here.

2. Portal
A one stop site for everything enterprise-related. This concept is getting tired. Or maybe we're just tired of it. SharePoint is no longer branded as a “portal server” in the 2007 version (though the word is still in the product API Namespace). However, SharePoint still is a portal framework and web parts are still portlets. In fact, this remains one of the primary differentiators between the pay per CAL SharePoint version and the free WSS offering. Some new goodness with Master Pages, new flexibility with a pluggable Single Sign-on architecture, better search, and much improved Visual Studio integration will help on the portal side, but overall its not that exciting to talk about.

3. Enterprise Search
Search was a bit of a painful thing with SPS 2003, especially when it came to integrating various content stores. The core problems have been addressed and the functionality broadly expanded. MOSS 2007 opens up ACL-aware search across both local and remote data stores with features that enable specialized search for people and expertise. The ability to index and search data in line-of-business apps via the Business Data Store integration is powerful and will please both business managers and developers alike. The new “Best Bets” feature adds a new depth of intelligence — pulling search hits from entitled by not included search scopes. There's new meat here. We feel that in this 2007 release, SharePoint search is transforming from a check box to a compelling feature.

4. Web & Enterprise Content Management
This is the big one for us. Microsoft is including core document management, major and minor versioning, check-in/check-out document locking, rich descriptive metadata, workflow (via Windows Workflow Foundation), content type-based policies, auditing, and role-based-access controls at the document library, folder, and individual document levels. The 2007 release builds on these capabilities delivering enhanced authoring, business document processing, Web Content Management and publishing, records management (DoD 5015.2 certification coming soon), policy management, and support for multilingual publishing.

Whew. There's a lot happening here. There are several different MS engineering groups working away at these features. No question about it, the content management functionalities in MOSS have been expanded broadly and will continue to do so. Existing MCMS customers considering a growth path will not necessarily find an easy migration story. With that said, the pathway there is evolving, MS' CM Assessment Tool is helpful, and the partner community — migration, integration, and customization — is pitching its significant weight in.

5. Forms Driven Business Process
Microsoft has overhauled this aspect of SharePoint with XML driven InfoPath forms that are available on a variety of platforms including portable wireless devices. Client/Server based form maintenance has been centralized and improved for business processes for partner and customers. This area is not as close to our hearts, but is another dynamic one that captures attention. As InfoPath gains momentum and additional integration evolves between Visual Studio, InfoPath, and SharePoint, I predict we will a strong uptick in the developer community.

6. Business Intelligence
Finally, BI has been improved across the board with web-based dashboards on the macro level, server-based Excel Services and Excel Web Services API's, line of business application and data repository integration, and more sophisticated abilities to monitor key performance indicators. Despite Microsoft's Performance Point BI server, this is one area of MOSS that we feel has the ability to shift the market. SharePoint 2003 transformed workgroup document storage and collaboration. We believe that SharePoint 2007 aims to do the same thing with BI. By enabling business users to build-out simple integration, dashboarding, and PKI monitoring MS are definitely looking for the next dimension for SharePoint growth.

Read more...

Blog Popularty Partners

  ©All Right Reserved.

Back to TOP