Jan 11

Two very good articles on best practices for MOSS 2007 / WSS 3.0 installation:

MOSS 2007 Installation
http://www.sharepointforum.se/en-US/Wiki/Installation%20MOSS%202007.aspx

WSS 3.0 Installation
http://www.sharepointforum.se/en-US/Wiki/Installation%20WSS%203.0.aspx

Tagged with:
Jan 10

A known issue exists with SharePoint / MOSS 2007 that produces the following error when attempting to delete a master page form the master page gallery:

This item cannot be deleted because it is still referenced by other pages.

 

 

This error might be expected if the master page was still in use, but the error is shown regardless if other pages still reference the master page or not.

A Microsoft Knowledge Base article exists (http://support.microsoft.com/?kbid=926812) which suggests setting the master page to a hidden state, but sometimes that isn’t enough. There are times when it is more than just a clean up issue, often it really is necessary to completely remove the file.

To completely delete the master page, perform the following steps:

  1. Navigate to the Master Page Gallery page from the Site Settings page.
  2. Select ‘New’ | ‘Folder’ from the menu bar.
  3. Create the folder with a temporary name such as DeleteMe.
  4. Open the site with SharePoint Designer and navigate to the ‘_catalogs\masterpage’ folder.
  5. Drag and drop the master page to delete into the temporary folder created in the above steps.
  6. Close SharePoint Designer.
  7. Return to the Master Page Gallery and delete the temporary folder.
Tagged with:
Jan 10

Attempting to open a SharePoint document library in Windows Explorer view by choosing  ‘Actions’ | ‘Open with Windows Explorer’ on a Windows Server 2008 machine generates the following error:

Your client does not support opening this list with Windows Explorer.

 

This is because the ‘Web Client’ service is required, but not installed on Windows Server 2008 by default. The service can be installed as a part of the ‘Desktop Experience’ Windows feature. To install the ‘Desktop Experience’ Windows feature perform the following steps:

  1. Open ‘Server Manager’ from Administrator Tools.
  2. Highlight the ‘Features’ node under Server Manager.
  3. Click the ‘Add Features’ link on the right-hand side of the screen.
  4. Check ‘Desktop Experience’.
  5. Click ‘Next’.
  6. Click ‘Install’.
  7. You will be prompted to restart the server.

 

Thank you to Tihomir Ignatov for his post on this error.

Tagged with:
Dec 27

Requirement: Develop a Regular Expression to parse a single line of text considering any of the following combinations of City, State, and Zip Code valid:

  • City State
  • City<space>Name State
  • City, State
  • City<space>Name, State
  • City State Zip
  • City<space>Name State Zip
  • City, State Zip
  • City<space>Name, State Zip
  • Zip

Regular Expressions can be very powerful, but also can be a bit hard to develop and read. I would recommend using a good RegEx editor to help you build and test your expressions. Also, make sure to comment your expressions to assist in future maintenance and debugging.

After trying out a few RegEx tools, I recommend using Expresso which is available on the Ultrapico web site. The tool includes a 60 day trial period, and at the time of writing this article, the actual registration for the tool is also free.

To accomplish the above requirement, I found that using named groups and multiple or conditions (‘|’) was the best way to handle all the different combinations of City, State, and Zip Code I needed to support. This made it easy to allow for commas or the lack of commas and different spacing in the input text as well.

Using Expresso, I came up with the following Regular Expression:

(updated 2/4/2010 to allow for ‘.’ (period) and ‘-’ (dash) in City names)

#Parse address line into named groups (City, State, Zip)

^                         #Beginning of string

(                         #Start OR condition

(                         #Begin first condition (City, State, Zip)

(?<City>[A-Za-z\.\-\s]+)  #City

( (?:,\s?) | (?:\s?) )\b  #Comma, comma space, or space

(?<State>[A-Za-z]{2})     #State

(?:\s?)                   #Space

(?<Zip>\d{5}(-\d{4})?)    #Zip

) |                       #End first condition

(                         #Begin second condition (City, State)

(?<City>[A-Za-z\s]+)      #City

( (?:,\s?) | (?:\s?) )\b  #Comma, comma space, or space

(?<State>[A-Za-z]{2})     #State

(?:\s?)                   #Space

) |                       #End second condition

(                         #Begin third condition (Zip)

(?<Zip>\d{5}(-\d{4})?)    #Zip

)                         #End third condition

)                         #End OR condition

$                         #End of string

 

I then incorporated the new Regular Expression into a simple .NET console application to test. The application prompts for an input and then outputs any valid combinations that are matched. The complete listing for the console application is below.

using System;

using System.Text;

using System.Text.RegularExpressions;

 

namespace ConsoleApplication1

{

  class Program

  {

    static void Main(string[] args)

    {

      string addressToParse = String.Empty;

      Console.WriteLine("Sample RegEx application to parse combinations of City, State, and Zip Code.");

      Console.WriteLine();

      Console.Write("Enter address or <Enter> to Quit: ");

 

      while (true)

      {

        addressToParse = Console.ReadLine();

        if (addressToParse.Length > 0)

        {

          ParseAddressSegments(addressToParse);

          Console.WriteLine();

          Console.Write("Enter address or <Enter> to Quit: ");

        }

        else

        {

          break;

        }

      }

    }

 

    private static void ParseAddressSegments(string addressToParse)

    {

      StringBuilder pattern = new StringBuilder();

      pattern.Append(@"#Parse address line into named groups (City, State, Zip)" + Environment.NewLine);

      pattern.Append(@"^                         #Begining of string" + Environment.NewLine);

      pattern.Append(@"(                        #Start OR condition" + Environment.NewLine);

      pattern.Append(@"(                        #Begin first condition (City, State, Zip)" + Environment.NewLine);

      pattern.Append(@"(?<City>[A-Za-z\.\-\s]+)  #City" + Environment.NewLine);

      pattern.Append(@"( (?:,\s?) | (?:\s?) )\b  #Comma, comma space, or space" + Environment.NewLine);

      pattern.Append(@"(?<State>[A-Za-z]{2})    #State" + Environment.NewLine);

      pattern.Append(@"(?:\s?)                  #Space" + Environment.NewLine);

      pattern.Append(@"(?<Zip>\d{5}(-\d{4})?)    #Zip" + Environment.NewLine);

      pattern.Append(@") |                      #End first condition" + Environment.NewLine);

      pattern.Append(@"(                        #Begin second condition (City, State)" + Environment.NewLine);

      pattern.Append(@"(?<City>[A-Za-z\s]+)      #City" + Environment.NewLine);

      pattern.Append(@"( (?:,\s?) | (?:\s?) )\b  #Comma, comma space, or space" + Environment.NewLine);

      pattern.Append(@"(?<State>[A-Za-z]{2})    #State" + Environment.NewLine);

      pattern.Append(@"(?:\s?)                  #Space" + Environment.NewLine);

      pattern.Append(@") |                      #End second condition" + Environment.NewLine);

      pattern.Append(@"(                        #Begin third condition (Zip)" + Environment.NewLine);

      pattern.Append(@"(?<Zip>\d{5}(-\d{4})?)    #Zip" + Environment.NewLine);

      pattern.Append(@")                        #End third condition" + Environment.NewLine);

      pattern.Append(@")                        #End OR condition" + Environment.NewLine);

      pattern.Append(@"$                         #End of string" + Environment.NewLine);

 

      Regex rgx = new Regex(pattern.ToString(), RegexOptions.IgnoreCase

                                                | RegexOptions.CultureInvariant

                                                | RegexOptions.IgnorePatternWhitespace

                                                | RegexOptions.Compiled);

      Match match = rgx.Match(addressToParse);

      if (match.Success)

      {

        foreach (string name in rgx.GetGroupNames())

        {

          if ( (match.Groups[name].Value != String.Empty) && (name == "City" || name == "State" || name == "Zip"))

          {

            Console.WriteLine(@"{0} = ""{1}""", name, match.Groups[name].Value.Trim());

          }

        }

      }

    }

 

  }

}

Download the sample Visual Studio 2008 solution.

Happy RegEx coding!

Tagged with:
Dec 17

Using the syntax ‘DropDownList1.SelectedIndex = 10;’ does not create an exception, but using the syntax ‘DropDownList.Items.FindByValue(“10”).Selected = true;’ can create the following exception:

Cannot have multiple items selected in a DropDownList.   at System.Web.UI.WebControls.DropDownList.VerifyMultiSelect()

Calling ClearSelection() on the DropDownList first will avoid this exception. It is also a good idea to first check and make sure that the value actually exists as an item within the DropDownList as in the following example:

private void SetDropDownListSelectedItem(string selectedValue)

{

  ListItem li = DropDownList1.Items.FindByValue(selectedValue);

  if (li != null)

  {

    DropDownList1.ClearSelection();

    li.Selected = true;

  }

}

Tagged with:
Dec 15

A simple method to highlight the text within a textbox control when the control gets the focus:

protected void Page_Load(object sender, EventArgs e)

        {

            //Add client javascript to highlight the value when the control receives the focus

            txtMyTextBox.Attributes.Add("onfocus", "this.select();");

        }


This is a nice and easy way to highlight a default value in a form or a search box.

Tagged with:
Dec 07

IIS 7 did not carry over many of the VBS scripts that IIS 6 came with. In particular, IISAPP.vbs which was a tool used to list the running worker processes, is no longer available on IIS 7 / Windows Server 2008. IISAPP.vbs was often used to determine which IIS process to attach your Visual Studio debugger to.

Fortunately, AppCmd.exe, which is a more powerful tool, can be used to accomplish the same task. For instance, to list the running worker processes, issue the following command: C:\Windows\System32\inetsrv\appcmd.exe list wp

A good write up on AppCmd.exe can be found at: http://learn.iis.net/page.aspx/114/getting-started-with-appcmdexe

Tagged with:
Dec 04

While working with Visual Studio 2008 / VseWSS projects I occasionally see the following COM exception preventing the VS project from packaging or deploying to SharePoint:

Error: System.Runtime.InteropServices.COMException
System.Runtime.InteropServices.COMException (0×80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.

It turns out, at least in my experience, that this is caused by an error within the manifest.xml file which typically is due to a renamed file or a change in the project’s directory structure.

To resolve:

  1. Manually edit the manifest.xml correcting any errors and save.
  2. Close Visual Studio 2008 and then re-open the project.

The VseWSS project should now package/ deploy without error.

Tagged with:
Nov 30

On a fresh install of Windows Server 2008, MOSS 2007, Visual Studio 2008, and the Visual Studio Extensions for Windows SharePoint Services I received the following error when trying to deploy or package a solution with VseWSS:

The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: ‘<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

Apparently the VseWSS CTP 1.3 uses the WCF in the deployment process and requires the Windows Server 2008 WCF HTTP Activation feature to be activated. To activate the WCF feature in Windows Server 2008 use the following steps:

  1. Open ‘Server Manager’ from Administrator Tools.
  2. Highlight the ‘Features’ node under Server Manager.
  3. Click the ‘Add Features link on the right-hand side of the screen.
  4. Expand the ‘.NET Framework 3.0 Features’ node.
  5. Expand the ‘WCF Activation’ node.
  6. Check ‘HTTP Activation’ (required). Optionally you mat wish to check the ‘Non-HTTP Activation’ feature if you will be using WCF projects that utilize this, but it is not required for the VseWSS to work.
  7. Click Next to install.
Tagged with:
Nov 29

I have noticed the following error a few times when activating the MOSS Publishing Infrastructure feature on a newly created site collection:

Failed to activate feature ‘PublishingPrerequisites’ (ID: a392da98-270b-4e85-9769-04c0fde267aa) at scope ‘http://[url]‘.

Typically opening a command prompt (as administrator) and running an ‘iisreset /noforce’ will resolve this error.

Tagged with:
preload preload preload