CJ

The circle of life – ** .Net – Training – MOSS **

  • Past Post

  • Vistor Locations

Archive for the ‘WSS 3.0’ Category

Site and Application pages

Posted by CJ on August 24, 2007

This is a common question I receive:
Why do certain pages in my site display the correct master page, while other pages look totally different?

This is because there are two types of pages in a wss application, site pages and application pages.

Site pages are directly related to a wss site and are customisable for that specific site. They point to the sites master page and live inside the content database.

Application pages are very different. They are physical files on the file system that live in a special directory called Layouts (12\Templates\Layouts). This directory is available to all web applications (in a farm installation) using a relative URL which is created when the web application is created. So this means that all Application pages are available to all sites and each application page is reused by all sites. i.e. The .aspx page at http://moss/_layouts/recyclebin.aspx, http://moss/sites/Sales/_layouts/recyclebin.aspx and http://intranet/_layouts/recyclebin.aspx are all the same .aspx page.

If you customise one of these files then you are changing it for the entire farm. Application pages also have their own master page called application.master that lives in 12\Templates\Layouts.

So, if you are navigating around your site and your sites look and feel suddenly changes then it will be due to you navigating from a site page to an application page (http://moss/_layouts/recyclebin.aspx or http://moss/_layouts/siteesettings.aspx).

Posted in WSS 3.0 | Leave a Comment »

Fast Application Pool Recycler: and its free

Posted by CJ on July 26, 2007

I just came across a great tool for recycling IIS application pools or even performing an IIS Reset. Simply click the system tray utility and select the application pool you want to recycle.

This tool is especially useful for WSS/MOSS developers who need to regularly recycle application pools when developing in the SharePoint environment.

http://www.harbar.net/articles/APM.aspx

Quote from site
“This freeware application is a System Tray utility for providing quick access to common IIS tasks which are useful on a SharePoint development box. It may also be useful to others working with IIS. In essence, it enumerates the app pools on your box and lets you right click ‘em to bounce ‘em!

For those who like the old fashioned way then you can wrap this up in a .bat file

cscript c:\windows\system32\iisapp.vbs /a “%SharePointAppPool%” /r

Where %SharePointAppPool% is the app pool you are wanting to cycle.

Or you can use issapp from a command prompt to view the process id – thanks Doug

Posted in MOSS 2007, WSS 3.0 | Leave a Comment »

MOSS, AJAX and the AutoCompleteExtender

Posted by CJ on July 8, 2007

This article will look at utilising ASP.Net 2.0 AJAX inside WSS 3.0. This article is also based off some great work completed by Todd Bleeker in his book Developers Guide To Windows SharePoint Services 3.0.

To complete the code associated with this article you will need to install ASP.Net 2.0 AJAX Extensions and the ASP.Net 2.0 AJAX Control Toolkit as we will be utilising AJAX Extensions, namely the AutoCompleteExtender control.

The first thing you need to do is make your WSS site AJAX ready. This blog article from the SharePoint team takes you through the steps in completing this and also has a nice little web part example to test and make sure everything is working as it should be.

Ok, what we are going to demonstrate is creating an AutoComplete Web Part that provides users with the ability to filter a drop down list as they type in a text box. See image below. This will be a two step process, firstly creating a web service that is the data source for the drop down list, and secondly creating the AutoComplete Web Part. I must also point out that there is no difference between creating this Web Part in WSS 3.0 or any standard ASP.Net 2.0 application (which is what WSS is J).

Web Service

  1. Open VS.Net and choose ASP.Net AJAX Enabled Web Site template (if you don’t see this option then you need to install ASP.Net 2.0 AJAX)
  2. Ensure location is HTTP and enter a URL like http://localhost/WebServices.
  3. In Solution Explorer, right click the project name and add a new item. Choose Web Service from the templates window.
  4. Enter SimpleWebService for the name and uncheck the Select code in separate file checkbox.
  5. Decorate the class with the ScriptService to enable AJAX calls.

    [Microsoft.Web.Script.Services.ScriptService]
    public class SimpleWebService : System.Web.Services.WebService

  6. Create a WebMethod that will return a list of employees. The WebMethod must conform to the precise interface expected by the AutoComplete extender control which includes two arguments that must be named prefixText and count. The prefixText argument contains the letters typed by the end user and the count contains the maximum number of items returned.

    [WebMethod]

    [Microsoft.Web.Script.Services.Script]Method]

    public System.Collections.Generic.List<string> GetEmployees(string prefixText, int count)

    {

                    string[] employees = new string[]{

    “Adam Wells”,

    “James MacGuire”,

    “Jeff Phillps”,

    “Jemma Knowles”,

    “Mary Jullop”,

    “Mark Dent”};

    System.Collections.Generic.List<string> employeeList = new System.Collections.Generic.List<string>();

    Int i = 0;

    foreach(string employee in employees)

    {

                    //check if max number of employees has been reached

                    if(i == count)

                    {

                                    break;

    }

    else if(employee.ToLower().StartsWith(preficText.ToLower()))

    {

                    employeeList.Add(employee);

                    i++;

    }

    }

    return employeeList;

    }

    This WebMethod returns a string array containing the first and last name for employees. This example could easily be altered to return a result from a database.

  7. This ends the Web Service/WebMethod necessary for the AutoCompleteExtender control.

Ok, now for the Web Part.

  1. Open VS.Net and create a new Class Library project. Enter AJAXStyleWebParts for the name.
  2. Add a reference to the ASP.Net AJAX assembly (Microsoft.Web.Extension.dll), and to the toolkit assembly AjaxControlToolKit (the extender controls are not found in the core ASP.Net AJAX assembly and you will need to build the ToolKit solution that you downloaded previously at the beginning of the article).
  3. Add a new class called AutoCompleteWebPart : System.Web.UI.WebControls.WebParts.WebPart (and inherit WebPart class)
  4. Add declarations to the top of the class:using

    using System.Web;

    using System.Web.UI.WebControls;
    using AjaxControlToolkit;

  5. Override the CreateChildControls method
  6. protected override void CreateChildControls()

    {

                //establish a path to the web service

                string webServicePath = “http://localhost/WebServices/SimpleWebService.asmx”; 

                try

    {

    //TextBox label

    Literal textboxLabel = new Literal();

    textboxLabel.Text = “”Type the name of a Employee: “;

    this.Controls.Add(textboxLabel);

     

    //TextBox to extend with the AutoComplete AJAX behaviour. Note: this is a normal asp textbox

    TextBox textbox = new TextBox();

    textbox.Attributes.Add(“id”, “SelectEmployeeTextBox”);

    this.Controls.Add(textbox);

     

    //autocomplete AJAX behaviour

    AutoCompleteExtender autoComplete = new AutoCompleteExtender();

    autoComplete.MinimumPrefixLength = 1;

    autoComplete.ServicePath = webServicePath;

    autoComplete.ServiceMethod = “GetEmployees”;

    autoComplete.TargetControlID = “SelectEmployeeTextBox”;

    this.Controls.Add(autoComplete);

    }

    catch(Exception ex)

    {

                    Literal errMsg = new Literal();

                    errMsg.Text = ex.Message;

                    this.Controls.Add(errMsg);

    }

    }

  7. This ends our AutoComplete Web Part. Now all we have to do deploy to the web applications bin directory or GAC, add a safe control entry, recycle the app pool, add the Web Part to the gallery and then add to your WSS page.
  8. Type the letters “mar” in the textbox to see the Web Part in action.
  9. So, now you have AJAX’ed your WSS site, created a Web Part and implemented the AutoCompleteExtender control which I think provides great functionality for any WSS site.

Posted in .NET 2.0, Articles, WSS 3.0 | 20 Comments »

Windows SharePoint Services 3.0 Tools: Visual Studio 2005 Extensions

Posted by CJ on July 3, 2007

Posted in WSS 3.0 | Leave a Comment »

Regular Expression Validation Custom Field Type

Posted by CJ on May 15, 2007

I have been reading Todd Bleekers book Developers Guide To Windows SharePoint Services 3.0 and came across a great implementation in creating a custom field type in WSS 3.0. This custom field type is a Regular Expression Validation Custom Field Type. I love this implementation as it can be used for many situations…anywhere you want to validate input using regular expressions.

  • Emails

  • Telephone numbers

  • Address

  • Numbers only

  • Letters only

  • Alphanumeric only

If you are after a regular expression to validate input then this is one of the best sites to use.

Here are a couple of screen shots that displays the objective.



A Custom Field Type is a class that is complied into an assembly, so the first thing to do is open VS.NET 2005 and create a new Class Library project.

  • Provide a meaningful project name

  • You need to add an assembly reference to Windows SharePoint Services 12.0.0.0 in the .Net project.

  • Rename the default class Class1.cs to RegExTextField.cs. (VS.NET will refactor the project to update the related references to the new class name)

  • Add two directives to the top of the class.

    • using Microsoft.SharePoint

    • using System.Text.RegularExpressions

  • You need to now inherit functionality so it behaves like a CFT. There are many different CFT classes you can inherit from to get different behaviour, but we want to inherit the SPFiledText as this most resembles our CFT. So the declaration will look like the following

    • public class RegExTextField : SPFieldText

  • WSS v3 will call into one of two constructors so the class must implement both of them even though they don’t implement any code.

    • public RegExTextField(SPFieldCollection fields, string fieldName)
      : base(fields, fieldName)
      { }

    • public RegExTextField(SPFieldCollection fields, string typeName, string displayName)
      : base(fields, typeName, displayName)
      { }

  • The GetValidatedString method converts the field type value into a validated serialised string. We can use this method to create our own custom validation from the value entered. Insert this after the second constructor.

    public override string GetValidatedString(object value)
    {
        string textValue = value.ToString();

    //Only compare RegEx if a value is present
    if (textValue.Length > 0)
    {
        //setup regex based on custom property
        Regex reg = new Regex(GetCustomProperty(“RegularExpression”).ToString(), RegexOptions.IgnoreCase);

        //if the value entered does not match
        if (!reg.IsMatch(textValue))
        {
            throw new SPFieldValidationException(GetCustomProperty(“ExceptionMessage”).ToString());
        }
        else
        {
            return textValue;
        }
    }
    else
    {
        return textValue;
    }
}

  • Sign the assembly so it can be deployed to the GAC. You can sign the assembly by navigating to the Class Library project properties and click the Signing tab. Build the project to produce the assembly and deploy to the GAC.

Now you need to define what elements you want displayed when the CFT is used in the Create Column and Additional Columns Settings.

  • In the same Class Library project choose Add àNew Item and select XML File.
  • In the Name field type fldtypes_RegExTextField.xml. (The name of the file is important as CFTs must begin with fldtypes)
  • Add the following code to your .xml file

    <?xml version=”1.0″ encoding=”utf-8″ ?>
    <FieldTypes>
        <FieldType>
            <Field Name=”TypeName”>RegExTextField</Field>
            <Field Name=”ParentType”>Text</Field>
            <Field Name=”TypeDisplayName”>
                Single line of text (with RegEx validation)
            </Field>
            <Field Name=”FieldTypeClass”>
                CustomFieldTypes.RegExValidation.RegExTextField,
                CustomFieldTypes.RegExValidation, Version=1.0.0.0,
                Culture=neutral, PublicKeyToken=d7f772d26282eb60
            </Field>
            <PropertySchema>
                <Fields>
                    <Field Name=”RegularExpression” DisplayName=”Regular Expression” MaxLength=”255″ DisplaySize=”35″ Type=”Text”>
                        <Default></Default>
                    </Field>
                    <Field Name=”ExceptionMessage” DisplayName=”Exception Message” MaxLength=”255″ DisplaySize=”35″ Type=”Text”>
                        <Default></Default>
                    </Field>
                </Fields>
            </PropertySchema>
        </FieldType>
    </FieldTypes> 

    • The FieldType elements define the attributes associated with the CFT when it appears in the Name and Type section of the Create Column page.
    • The PropertySchema elements define the attributes associated when it appears in the Additional Column Settings (after you select the CFT radio button)

  • CFT have two scopes, Farm or List.

    • Farm: fldtypes*.xml files reside in the ..\12\Template\XML folder.
    • List: The schema.xml file that defines a list template can include CFTs.
  • Because this CFT will be useful across the farm we will copy it to the ..\12\Template\XML folder In Windows Explorer copy the fldtypes_RegExTextField.xml to ..\12\Template\XML.
  • Now all you have to do is perform an application pool recycle, then go to any WSS 3.0 list and add a new column and you will see your CFT.

Now you can use your new WSS 3.0 RegEx Validation CFT in many situations.

Posted in Articles, WSS 3.0 | 43 Comments »

WSS 3.0 Web Service Reference Guide

Posted by CJ on February 19, 2007

Update: 26 Jan 2008
Ali B has recently made me aware that MSFT has documented WSS web services on MSDN. You can find there here:
 http://msdn2.microsoft.com/en-us/library/ms445292.aspx


I found this on Glen’s site. Kudos to Glen.

Below is a list of all WSS 3.0 web services and their methods. This is not intended to be comprehensive documentation of each service and its methods. This is simply a quick list of web methods intended to simplify the process of finding a particular method.

Web Service
Methods

Admin Web Service
http://<AdminSite>/_vti_adm/Admin.asmx
Provides methods for managing a deployment of Microsoft Windows SharePoint Services, such as for creating or deleting site collections.
CreateSite
DeleteSite
GetLanguages
RefreshConfigCache


Alerts
http://<Site>/_vti_bin/Alerts.asmx
Provides methods for working with alerts for list items in a SharePoint site.
DeleteAlerts
GetAlerts


Authentication
http://<Site>/_vti_bin/Authentication.asmx
Login
Mode


Copy
http://<Site>/_vti_bin/Authentication.asmx
Provides methods for copying files to or from or within a SharePoint site.
CopyIntoItems
CopyIntoItemsLocal
GetItem


Document Workspace
http://<Site>/_vti_bin/Dws.asmx
Exposes methods for managing Document Workspace sites and the data they contain.
CanCreateDwsUrl
CreateDws
CreateFolder
DeleteDws
DeleteFolder
FindDwsDoc
GetDwsData
GetDwsMetaData
RemoveDwsUser
RenameDws
UpdateDwsData


Forms
http://<Site>/_vti_bin/Forms.asmx
Provides methods for returning forms that are used in the user interface when working with the contents of a list.
GetForm
GetFormCollection


Imaging
http://<Site>/_vti_bin/Imaging.asmx
Provides methods that enable you to create and manage picture libraries.
CheckSubwebAndList
CreateNewFolder
Delete
Download
Edit
GetItemsByIds
GetItemsXMLData
GetListItems
ListPictureLibrary
Rename
Upload


List Data Retrieval (StsAdapter)
http://<Site>/_vti_bin/DspSts.asmx
Represents the adapter service used to perform queries against sites and lists in Microsoft Windows SharePoint Services.
Query


Lists
http://<Site>/_vti_bin/Lists.asmx
Provides methods for working with lists and list data.
AddAttachment
AddDiscussionBoardItem
AddList
AddListFromFeature
ApplyContentTypeToList
CheckInFile
CheckOutFile
CreateContentType
DeleteAttachment
DeleteContentType
DeleteContentTypeXmlDocument
DeleteList
GetAttachmentCollection
GetList
GetListAndView
GetListCollection
GetListContentType
GetListContentTypes
GetListItemChanges
GetListItemChangesSinceToken
GetListItems
GetVersionCollection
UndoCheckOut
UpdateContentType
UpdateContentTypesXmlDocument
UpdateContentTypeXmlDocument
UpdateList
UpdateListItems


Meetings
http://<Site>/_vti_bin/Meetings.asmx
Enables you to create and manage Meeting Workspace sites.
AddMeeting
AddMeetingFromICal
CreateWorkspace
DeleteWorkspace
GetMeetingsInformation
GetMeetingWorkspaces
RemoveMeeting
RestoreMeeting
SetAttendeeResponse
SetWorkspaceTitle
UpdateMeeting
UpdateMeetingFromICal


People
http://<Site>/_vti_bin/People.asmx
ResolvePrincipals
SearchPrincipals


Permissions
http://<Site>/_vti_bin/Permissions.asmx
Provides methods for working with the permissions for a site or list.
AddPermission
AddPermissionCollection
GetPermissionCollection
RemovePermission
RemovePermissionCollection
UpdatePermission


Site Data
http://<Site>/_vti_bin/SiteData.asmx
Provides methods that return metadata or list data from sites or lists in Microsoft Windows SharePoint Services.
EnumerateFolder
GetAttachments
GetChanges
GetContent
GetList
GetListCollection
GetListItems
GetSite
GetSiteAndWeb
GetSiteUrl
GetURLSegments
GetWeb


Sites
http://<Site>/_vti_bin/Sites.asmx
Provides a method for returning information about the collection of site templates on the virtual server.
ExportWeb
GetSiteTemplates
GetUpdatedFormDigest
ImportWeb


Search
http://<Site>/_vti_bin/spsearch.asmx
The QueryService class is the entry point for calling the Search in Microsoft Windows SharePoint Services Query web service.
GetPortalSearchInfo (MOSS only)
GetSearchMetadata (MOSS only)
Query
QueryEx
RecordClick (MOSS only)
Registration
Status


Users and Groups
http://<Site>/_vti_bin/usergroup.asmx
Provides methods for working with users, role definitions, and groups.
AddGroup
AddGroupToRole
AddRole
AddRoleDef
AddUserCollectionToGroup
AddUserCollectionToRole
AddUserToGroup
AddUserToRole
GetAllUserCollectionFromWeb
GetGroupCollection
GetGroupCollectionFromRole
GetGroupCollectionFromSite
GetGroupCollectionFromUser
GetGroupCollectionFromWeb
GetGroupInfo
GetRoleCollection
GetRoleCollectionFromGroup
GetRoleCollectionFromUser
GetRoleCollectionFromWeb
GetRoleInfo
GetRolesAndPermissionsForCurrentUser
GetRolesAndPermissionsForSite
GetUserCollection
GetUserCollectionFromGroup
GetUserCollectionFromRole
GetUserCollectionFromSite
GetUserCollectionFromWeb
GetUserInfo
GetUserLoginFromEmail
RemoveGroup
RemoveGroupFromRole
RemoveRole
RemoveUserCollectionFromGroup
RemoveUserCollectionFromRole
RemoveUserCollectionFromSite
RemoveUserFromGroup
RemoveUserFromRole
RemoveUserFromSite
RemoveUserFromWeb
UpdateGroupInfo
UpdateRoleDefInfo
UpdateRoleInfo
UpdateUserInfo


Versions
http://<Site>/_vti_bin/Versions.asmx
Provides methods for working with file versions.
DeleteAllVersions
DeleteVersion
GetVersions
RestoreVersion


Views
http://<Site>/_vti_bin/Views.asmx
Provides methods for working with views of lists.
AddView
DeleteView
GetView
GetViewCollection
GetViewHtml
UpdateView
UpdateViewHtml
UpdateViewHtml2


Web Part Pages
http://<Site>/_vti_bin/WebPartPages.asmx
Provides methods for working with Web Parts.
AddWebPart
AddWebPartToZone
AssociateWorkflowMarkup
ConvertWebPartFormat
DeleteWebPart
ExecuteProxyUpdates
FetchLegalWorkflowActions
GetAssemblyMetaData
GetBindingResourceData
GetCustomControlList
GetDataFromDataSourceControl
GetFormCapabilityFromDataSourceControl
GetSafeAssemblyInfo
GetWebPart
GetWebPart2
GetWebPartCrossPageCompatibility
GetWebPartPage
GetWebPartPageConnectionInfo
GetWebPartPageDocument
GetWebPartProperties
GetWebPartProperties2
GetXmlDataFromDataSource
RemoveWorkflowAssociation
RenderWebPartForEdit
SaveWebPart
SaveWebPart2
ValidateWorkflowMarkupAndCreateSupportObjects


Webs
http://<Site>/_vti_bin/Webs.asmx
Provides methods for working with sites and subsites.
CreateContentType
CustomizeCss
DeleteContentType
GetActivatedFeatures
GetAllSubWebCollection
GetColumns
GetContentType
GetContentTypes
GetCustomizedPageStatus
GetListTemplates
GetWeb
GetWebCollection
RemoveContentTypeXmlDocument
RevertAllFileContentStreams
RevertCss
RevertFileContentStream
UpdateColumns
UpdateContentType
UpdateContentTypeXmlDocument
WebUrlFromPageUrl

Posted in Office 12, WSS 3.0 | 2 Comments »