Exclusive “Building the SharePoint User Experience” book excerpts posted

A few days ago I posted the first actual excerpts from my upcoming book "Building the SharePoint User Experience".

This is a good news/bad news situation. The bad news is that the excerpts are exclusive to the members of the mailing list. The good news is that all you need to do to get the excerpts is sign up to the list. Of course, the membership on the list is completely free and you get immediate access to the excerpts once you sign up. In fact, the password required to download is in the welcome message sent to you once you sign up.

Here’s what you will get:

1. Working with web parts in a site definition (from chapter 4)

This 3-page excerpt explains how you would add web parts to your site definition using the AllUsersWebPart element. In addition you will be shown how you get the actual web part code from an existing web part so that you can pre-configure settings to be included in the site definition web part.

(PDF, 4 pages)

2. DelegateControls (from chapter 5)

Modifying appearance and behavior of existing pages can be accomplished using DelegateControls. These controls allow you to put new controls and content into a pre-defined area of a page, such as the search box, various links, or, if you have created your own pages, anywhere you put a DelegateControl control. Learn how in this short excerpt.

(PDF, 3 pages)

3. A deep dive into Email-enabled lists (from chapter 7)

If you ever wanted to have an email enabled custom list you should understand how email works with lists. Then you would need to write a single line of code. This excerpt will explain and show you how email enabling works under the hood.

(PDF, 5 pages)

Here’s what you have to do to get the excerpts, in 3 easy steps:

1. Go to the Building the SharePoint User Experience blog and sign up for the mailing list.

2. Confirm your membership in the email sent to you. This is important! You will only get the password in the Welcome message.

3. Stop by the Exclusive book excerpts page and download the excerpts.

So far feedback on the excerpts has been great. Which is good, but also a bit disappointing. I mean, one important reason to post the excerpts is to get feedback on what to improve. I had hoped, at least sort of hoped, that people would run down my door, bashing me for using too much humor, putting in to few details, writing like a pig, or anything that I can use to improve the book.

I mean, I really want to write the best SharePoint book ever, and I refuse to believe that I am on track to do this just on my own. Oh, well, perhaps any new readers will be more brutal.

So, if you want to help me make this the best SharePoint Book ever, you know what to do…


PS! Remember, "Building the SharePoint User Experience" is available for pre-order at Amazon.

Found this article valuable? Want to show your appreciation? Here are some options:

a) Click on the banners anywhere on the site to visit my blog's sponsors. They are all hand-picked and are selected based on providing great products and services to the SharePoint community.

b) Donate Bitcoins! I love Bitcoins, and you can donate if you'd like by clicking the button below.

c) Spread the word! Below, you should find links to sharing this article on your favorite social media sites. I'm an attention junkie, so sharing is caring in my book!

Pin It

Linking to auto-join Group in SharePoint

Another question from a forum user:

"I am trying to create a link that will reproduce the same functionality that exists for the "Join Group" menu option when working with a SharePoint security Group.  I want to allow members to be able to Request Membership to a Specific SharePoint Group.  The group is set up to auto-accept.  The administrators of the site\group send out e-mails to members of the group.  For that reason we do not include everyone in the group by default.  But if they request access, they should be auto-approved.  Rather than trying to explain to users how to navigate to the Group Page where the "Action"-> "Join Group" menu option is, I would like to create a link from the home page to re-create the same functionality.

Any ideas? "

Why of course!

To understand how the link works we need to dig a bit. In contrast with regular Action links, the Join Group is not a CustomAction, which would have been too simple. Rather, the Join Group and Leave Group links are created only in the people.aspx page itself.

On opening that file we quickly find (search for Join or Leave group in the source) that the functionality is a JavaScript function call to JoinLeaveGroupClick(). That function in turn fires, through PostBack, an event receiver for the button. So we need to dig into the page code to find more.

.Net reflector to the rescue!

The ASPX page reveals that the page inherits the Microsoft.SharePoint.ApplicationPages.PeoplePage class. Using .Net reflector we open the Microsoft.SharePoint.ApplicationPages dll, usually located in [12]\CONFIG\BIN\Microsoft.SharePoint.ApplicationPages.dll. Browsing to the PeoplePage class we find the method that is fired:


Click on that method reveals the following code:

protected void BtnJoinLeaveGroup_Click(object sender, EventArgs e)
    string str;
    if (!this.CurrentGroup.AutoAcceptRequestToJoinLeave)
        str = "reqgroup.aspx?Group=" + SPHttpUtility.UrlKeyValueEncode(this.CurrentGroup.Name);
        str = "reqgroupconfirm.aspx?Action=";
        if (!this.CurrentGroup.ExplicitlyContainsCurrentUser)
            str = str + "Join&";
            str = str + "Leave&";
        str = str + SPHttpUtility.UrlKeyValueEncode("Group", this.CurrentGroup.Name);
    SPUtility.Redirect(str + "&" + SPHttpUtility.UrlKeyValueEncode("Source", SPHttpUtility.UrlPathEncode(base.CurrentRequestUrlAndQuery, false)), SPRedirectFlags.RelativeToLayoutsPage, this.Context);

From this we see that there is no Url that is used to add a user, but rather a method call to the SPGroup.Adduser method. Doh! No simple linking possible.

Or is it…?

To mimic the functionality we need to add a new page to hold the code for adding a user to a group. Since we have reflected the dll we know a bit about how that code should look as well, so let’s get down to business.

Creating a page to add users automatically

Start by creating a regular SharePoint application page using your favorite authoring tool. Since all we want to do is to add a user to a group, we just need to override the OnLoad method. Add the following to your .aspx file:

<%@ Assembly Name="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%>
<%@ Page Language="C#" Inherits="Microsoft.SharePoint.WebControls.LayoutsPageBase" MasterPageFile="~/_layouts/application.master"      %>
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
<%@ Import Namespace="Microsoft.SharePoint" %>

Of course, this doesn’t actually do anything, so we need to modify the overridden method. Substitute base.Onload(e); with this (Comments inline to explain what is going on):

protected override void OnLoad(EventArgs e)
    SPWeb web = SPContext.Current.Web;
    SPGroup currentGroup;
    // Get group id from query string
    string groupName = this.Page.Request["GroupName"];
    // Find Url to redirect user after addition
    string referringPage = "";
    if (this.Page.Request.UrlReferrer != null)
        referringPage = this.Page.Request.UrlReferrer.ToString();
        // Redirect to root url if direct link
        // You might want to modify this behavior
        referringPage = web.ServerRelativeUrl;
    // Get reference to current web and group
        currentGroup = web.Groups[groupName];
    catch (Exception ex)
        throw new SPException(ex.Message);
    // Add current user to group. Must allow unsafe updates since we are doing this through GET
    web.AllowUnsafeUpdates = true;
    web.AllowUnsafeUpdates = false;
    // Redirect user back to previous page.


Right. That should handle our code, so just save the file to the [12]\LAYOUTS directory, and add a link to test. You link should look something like this:


Note that an automatic adding to a group, such as this, requires that you have both set the "Allow reque
sts to join/leave this group? " and "Auto-accept requests?" to Yes. You can do this on the Group Settings page.

You might also want to improve on the code, add better error and exception handling, modifying the functionality of redirects, etc. but I will leave that as an exercise to you.

Let me know if you have problems.


Pin It

Modifying Title and Location fields in a SharePoint calendar

Question received by email:

"I am trying to make a solution involving a SharePoint Calendar.  Since I can not figure out
how to modify the Type of the Title and Location fields I simply hide them
from view and use my own custom fields for the job.

The trouble appears however when the SharePoint Calendar is viewed in
Outlook.  Outlook relies heavily on the Title and Location fields and since
the these fields are empty the entries appear as blank entries when the
Calendar is viewed in Outlook.

To resolve the issue I would like to find a way auto populate the Title and
Location fields when the user changes the value of my custom fields
(dropdowns).  Is this possible?  If so how can it be done ? or there is a
way to change the type of fields for title  or location to multiple choice
or any other type."

What you want can be accomplished using an event receiver. If you are up for some simple development stuff, check out my intro post on SharePoint Event Receivers.

If you don’t like programming or don’t know how, using a simple SharePoint Designer workflow can solve the same problem. There is a link to a walkthrough on SharePoint Designer Workflows in the above article.

You cannot change the title column. That column is inherited from the Item content type, just like most other Title column. In addition, the Title column has the property FromBaseType set, meaning you cannot change the type.

You could in theory change the Location column, but I advice against it. It is much better to use either a simple workflow or an event receiver to accomplish this.


Pin It