December 3rd, 2008 . by <Patrick/>
If you need to do a find and replace when outputting a column in a data view you can use the following:
�
<xsl:template name=”stringreplace”>
<xsl:param name=”stringvalue” />
<xsl:param name=”from” />
<xsl:param name=”to” />
<xsl:choose>
<xsl:when test=”contains($stringvalue, $from)”><xsl:value-of select=”substring-before($stringvalue, $from)” />
<xsl:if test=”contains(substring($stringvalue, 1, string-length($stringvalue) - 1), $from)”><xsl:value-of select=”$to” />
<xsl:call-template name=”stringreplace”>
<xsl:with-param name=”stringvalue” select=”substring-after($stringvalue, $from)” />
<xsl:with-param name=”from” select=”$from” />
<xsl:with-param name=”to” select=”$to” />
</xsl:call-template>
</xsl:if>
</xsl:when>
<xsl:otherwise><xsl:value-of select=”$stringvalue” /></xsl:otherwise>
</xsl:choose>
</xsl:template>
�
Call the template code:
Say you have a column named ColumnName and you want to replace all occurrences of True and set them to False…..
<xsl:call-template name=”stringreplace”>
<xsl:with-param name=”stringvalue” select=”@ColumnName” />
<xsl:with-param name=”from” select=”True” />
<xsl:with-param name=”to” select=”False” />
</xsl:call-template>
�
Posted in Sharepoint, MOSS |
No Comments »
October 26th, 2008 . by <Patrick/>
When opening an infopath form the XML code appears in the browser.
Open Infopath go into Tools / Options
Check – Check whether Microsoft Office is the default program for opening and editing .xml files
�
Posted in Sharepoint, MOSS, Infopath |
No Comments »
September 26th, 2008 . by <Patrick/>
When you migrate a form library from Sharepoint 2003 to Sharepoint 2007 references to the Form template will still point to the 2003 form library.
If you need to update the reference Sharepoint has a relink documents feature to individually re-link the xml forms to the appropriate template.
Unfortunately this process can be rather cumbersome especially if the form library contains sub folders. To alleviate this painful process
I developed a tool that with go through an entire directory structure recursively and do a find and replace on the template (.XSN) file.
What you will need to do is go into the explorer view of the form library, copy all files and folders to a location on your local hard drive.
Then open up the “UpdateInfopathTemplate” utility and update all the xml forms. Then copy all the forms back to the destination form library in 2007.

Click here to download the utility
Posted in Sharepoint, MOSS, Infopath |
No Comments »
August 26th, 2008 . by <Patrick/>
The Stock Quote Web Part is a custom web part that displays stock information from Yahoo Finance. It allows users to lookup stocks on either the TSE or NYSE

Click here to dowload the Web Part
�
Posted in Sharepoint, WSS, MOSS |
No Comments »
July 26th, 2008 . by <Patrick/>
Below is some code to get you started on creating your own Sharepoint Application Page so that it looks just like the built in ones!
<%@ Assembly Name=”Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”%>
<%@ Assembly Name=”CheckInAll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=70b886b56e89f448″ %>
<%@ Page Language=”VB” MasterPageFile=”~/_layouts/application.master” Inherits=”VSeWSS.CheckInAll.CheckIn” %>
<asp:Content ID=”PageTitle” contentplaceholderid=”PlaceHolderPageTitle” runat=”server”>
Check-In: All Documents
</asp:Content>
<asp:Content ID=”PageTitleInTitleArea” runat=”server”
contentplaceholderid=”PlaceHolderPageTitleInTitleArea” >
Check-In: All Documents
</asp:Content>
<asp:Content ID=”Main” contentplaceholderid=”PlaceHolderMain” runat=”server”>
<table>
<tr>
<td class=”ms-descriptiontext” valign=”top”>
<table border=”0″ cellpadding=”1″ cellspacing=”0″ width=”100%”>
<tr>
<td class=”ms-sectionheader” style=”padding-top: 4px;” height=”22″ valign=”top”>
<H3 class=”ms-standardheader”>
Check-In Document
</H3>
</td>
</tr>
<tr>
<td class=”ms-descriptiontext ms-inputformdescription”>
�
Add comments to all the documents you are checking in
�
</td>
<td><IMG SRC=”/_layouts/images/blank.gif” width=8 height=1 alt=”"></td>
</tr>
<tr>
<td><IMG SRC=”/_layouts/images/blank.gif” width=150 height=19 alt=”"></td>
</tr>
</table>
</td>
<td class=”ms-authoringcontrols ms-inputformcontrols” valign=”top”
align=”left” >
<table border=”0″ width=”100%” cellspacing=”0″ cellpadding=”0″>
<tr>
<td width=”9px”><IMG SRC=”/_layouts/images/blank.gif” width=9 height=7 alt=”"></td>
<td><IMG SRC=”/_layouts/images/blank.gif” width=150 height=7 alt=”"></td>
<td width=”10px”><IMG SRC=”/_layouts/images/blank.gif” width=10 height=1 alt=”"></td>
</tr>
<tr>
<td />
<td class=”ms-authoringcontrols”>
<table class=”ms-authoringcontrols” border=”0″ width=”100%” cellspacing=”0″ cellpadding=”0″>
�
�
<tr id=”ctl00_PlaceHolderMain_ctl01_ctl02_tablerow1″>
<td class=”ms-authoringcontrols” colspan=”2″ nowrap>
<label for=”ctl00_PlaceHolderMain_ctl01_ctl02_InputFile” id=”ctl00_PlaceHolderMain_ctl01_ctl02_LiteralLabelText”>Comments:</label>
</td>
</tr>
<tr id=”ctl00_PlaceHolderMain_ctl01_ctl02_tablerow2″>
<td><IMG SRC=”/_layouts/images/blank.gif” width=1 height=3 alt=”"></td>
</tr>
<!– End Right_Text –>
<tr id=”ctl00_PlaceHolderMain_ctl01_ctl02_tablerow3″>
<td width=”11″ ><IMG SRC=”/_layouts/images/blank.gif” width=11 height=1 alt=”"></td>
<td class=”ms-authoringcontrols” width=”99%”>
�
<TABLE class=”ms-authoringcontrols” width=”100%”>
<TR><TD>
<SPAN dir=”ltr”>
<asp:TextBox runat=”server” Width=”350px” ID=”txtComments” TextMode=”MultiLine” Rows=”5″></asp:TextBox>
</SPAN>
</TD></TR>
</TABLE>
�
</td>
</tr>
�
<tr id=”ctl00_PlaceHolderMain_ctl01_ctl02_tablerow5″>
<td><IMG SRC=”/_layouts/images/blank.gif” width=1 height=6 alt=”"></td>
</tr>
</table>
</td>
<td width=”10px”><IMG SRC=”/_layouts/images/blank.gif” width=10 height=1 alt=”"></td>
</tr>
<tr>
<td />
<td><IMG SRC=”/_layouts/images/blank.gif” width=150 height=13 alt=”"></td>
<td />
</tr>
</table>
</td>
</tr>
�
<tr>
<td height=”2px” class=”ms-sectionline” colspan=”2″>
<IMG SRC=”/_layouts/images/blank.gif” width=1 height=1 alt=”">
</td>
</tr>
�
<tr>
<td height=”10px” class=”ms-descriptiontext” colspan=”2″>
<IMG SRC=”/_layouts/images/blank.gif” width=1 height=10 alt=”">
</td>
</tr>
<tr>
<td colspan=”2″>
<table cellpadding=”0″ cellspacing=”0″ width=”100%”>
<colgroup>
<col width=”99%”>
<col width=”1%”>
</colgroup>
<tr>
<td>
</td>
<td nowrap>
<asp:Button ID=”btnOK” Text=”OK” Width=”100px” runat=”server” />
<asp:Button ID=”btnCancel” OnClientClick =”window.location=history.back();” Width=”100px” Text=”Cancel” runat=”server” />
</td>
</tr>
</table>
</td>
</tr>
�
<tr>
<td height=”40″ class=”ms-descriptiontext” colspan=”2″>
<IMG SRC=”/_layouts/images/blank.gif” width=1 height=4 alt=”">
</td>�
</tr>
�
</td>
</table>
</asp:Content>
Posted in Sharepoint, WSS, MOSS, Visual Studio |
No Comments »
June 25th, 2008 . by <Patrick/>
Here’s a very simple way to populate a TreeView Control using the SPSiteMapProvider.
Just copy the code below, create an aspx page, name it what you want and then copy it to
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS
Code for the application page:
<%@ Assembly Name=”Microsoft.SharePoint.ApplicationPages, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”%>
<%@ Page language=”C#” MasterPageFile=”~/_layouts/application.master” %>
<%@ Import Namespace=”Microsoft.SharePoint.ApplicationPages” %>
<%@ Register Tagprefix=”SharePoint” Namespace=”Microsoft.SharePoint.WebControls” Assembly=”Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<%@ Register Tagprefix=”Utilities” Namespace=”Microsoft.SharePoint.Utilities” Assembly=”Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<%@ Register Tagprefix=”WebPartPages” Namespace=”Microsoft.SharePoint.WebPartPages” Assembly=”Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<%@ Register Tagprefix=”wssawc” Namespace=”Microsoft.SharePoint.WebControls” Assembly=”Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<%@ Register Tagprefix=”SharePoint” Namespace=”Microsoft.SharePoint.WebControls” Assembly=”Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<%@ Register TagPrefix=”wssuc” TagName=”ButtonSection” src=”~/_controltemplates/ButtonSection.ascx” mce_src=”~/_controltemplates/ButtonSection.ascx” %>
<%@ Import Namespace=”Microsoft.SharePoint” %>
<%@ Import Namespace=”Microsoft.SharePoint.Navigation” %>
<%@ Import Namespace=”System.Net” %>
<asp:Content ID=”Content1″ ContentPlaceHolderId=”PlaceHolderPageTitle” runat=”server”>
<asp:Literal id=”PageTitleLabel1″ runat=”server” ></asp:Literal>
</asp:Content>
<asp:Content ID=”Content2″ ContentPlaceHolderId=”PlaceHolderPageTitleInTitleArea” runat=”server”>
<asp:Label id=”PageTitleLabel” runat=”server” ></asp:Label>
</asp:Content>
<asp:Content ID=”Content3″ ContentPlaceHolderId=”PlaceHolderAdditionalPageHead” runat=”server”>
<script runat=”server”>
void Page_Load(object sender, System.EventArgs e)
{
SPSiteMapProvider sitemapProvider = (SPSiteMapProvider)SiteMap.Providers[”SPSiteMapProvider”];
SiteMapDataSource datasource = new SiteMapDataSource();
datasource.Provider = sitemapProvider;
this.TreeView1.DataSource = datasource;
this.TreeView1.ExpandDepth = 1;
this.TreeView1.DataBind();
}
</script>
</asp:Content>
<asp:Content ID=”Content4″ ContentPlaceHolderId=”PlaceHolderPageImage” runat=”server”>
<img src=”/_layouts/images/blank.gif” mce_src=”/_layouts/images/blank.gif” width=1 height=1 alt=”" />
</asp:Content>
<asp:Content ID=”Content5″ ContentPlaceHolderId=”PlaceHolderPageDescription” runat=”server”>
�
<table cellpadding=”2″ cellspacing=”1″ width=”100%” class=”ms-informationbar” style=”margin-bottom: 5px;” border=0>
<tr>
<td width=”10″ valign=”middle” style=”padding: 4px”>
<img id=”Img1″ src=”/_layouts/images/exclaim.gif” mce_src=”/_layouts/images/exclaim.gif” alt=”<%$Resources:wss,exclaim_icon%>” runat=”server”/>
</td>
<td class=”ms-descriptiontext”>
<SharePoint:EncodedLiteral ID=”EncodedLiteral1″ runat=”server” text=”Please select the site you wish to visit” EncodeMethod=’HtmlEncode’/>
</td>
</tr>
�
</table>
<asp:PlaceHolder id=”PublishDescription” Visible=”true” runat=”server”>
<tr>
<TD height=”8px”><img src=”/_layouts/images/blank.gif” mce_src=”/_layouts/images/blank.gif” width=”1″ height=”8″ alt=”"></td>
</tr>
�
<tr>
�
<td colspan=”2″>
�
<table width=”100%”>
<tr>
<td class=”ms-formbody”>
<asp:TreeView�
ID=”TreeView1″
ExpandDepth=”3″
Font-Names= “Arial”
Font-Size=”10pt”
ForeColor=”Blue”
NodeWrap=”true”
runat=”server”
>
</asp:treeview>
</td>
</tr>
</table>
</td>
</tr>
</asp:PlaceHolder>
</asp:Content>
Posted in Sharepoint, ASP.Net, WSS, MOSS |
No Comments »
May 28th, 2008 . by <Patrick/>
After reading the DataCogs article on Sharepoint – Cascading Drop Down Lists I was inspired to take the challenge and modify the code to allow for an infinite number of cascading drop downs. I learned alot from the article, and I would highly reccomend anyone trying to create their own custom fields in Sharepoint to read it. The current code has a parent child relationship however you cannot include a grandchild dropdown.
In my humble solution, I have a drop down of continents, then a related drop down for countries and then a third dropdown with the related cities.

I created three lists:
Continents

Countries

Cities

Then I created a new list where I add the three custom field type Cascading DropDown Fields to the list



I added three new fields to the Cascading DropDown List Details section.
Name - the name of the field this should be a unique name to identify the field
Parent Name - name of the parent DropDown list control if there is one
Child Name - name of the child DropDown list control if there is one
The first custom field I added was the Continent and named it MyContinent for a
lack of a better name and I set the child to be MyCountry
The second custom field I added was the Country and named it MyCountry and added
MyContinent as the parent and MyCity as the child
The third custome field I added was the City and named it MyCity and added MyCountry
as the parent and left the child blank
Once my list was configured, I was on my way to the races.
The code available for download below is part of a Sharepoint solution.
In order to install it on your Sharepoint installation open up a command prompt,
navigate to the Solution folder wherever you unzipped the code to and run the Install.bat
file. I have also included an Uninstall.bat file. I haven’t quite had enough
time yet to get it to work as a feature but I plan to in the weeks ahead. Before running the solution make sure you have the makecab.exe utility. The Microsoft Cabinet Software Development Kit can be downloaded here.
Download code
For references on how to package up solutions the following are good articles to read:
Patrick Tisseghem’s Development Tools and Techniques for Working with Code in Windows SharePoint Services 3.0
Scot Hillier’s What’s Your Process for Developing SharePoint Features and Solutions?
Read the rest of this entry »
Posted in Sharepoint, MOSS |
1 Comment »
April 26th, 2008 . by <Patrick/>
Sometimes you want to fomat your Data View columns in a special way but Sharepoint Designer dissapoints you. The answer is to get dirty and modify the XSL in the Code behind the Data View web part.
I had a requirement to display a delimitted string comming from a column on multiple lines something like this:
In the list the URL column was a pipe delimitted string (from Infopath) that looked like this:
http://www.microsoft.com%7chttp//www.12thwave.com%7Chttp://blog.12thwave.com
There are several XPath functions that could be used but unfortunately Sharepoint only supports XPath version 1.0 and all the good functions are in version 2.0 like tokenize() and split()
At first I tried the following technique (creating an xml file and adding it as a secondary data connection but for some reasone it did not like the hyperlinks I had) see: Inserting line breaks into text using Rules
I came across an excellent site that provided me with a bunch of great xsl string functions where I found the solution:
http://www.dpawson.co.uk/xsl/sect2/N7240.html#d11074e349
Create a data view and use the following template
<xsl:template name=”links”>
<xsl:param name=”str”/>
<xsl:choose>
<xsl:when test=”contains($str,’|')”>
<a href=”{substring-before($str,’|')}” mce_href=”{substring-before($str,’|')}”><xsl:value-of
select=”substring-before($str,’|')”/></a>
<xsl:text> </xsl:text><br/>
<xsl:call-template name=”links”>
<xsl:with-param name=”str” select=”substring-after($str,’|')”/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<a href=”{$str}” mce_href=”{$str}”><xsl:value-of select=”$str”/></a>
<xsl:text> </xsl:text><br/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Then output your URL field like so:
<td>
<xsl:call-template name=”links”>
<xsl:with-param name=”str” select=”substring-after(@URL, ‘, ‘)” />
</xsl:call-template>
</td>
Posted in Sharepoint, WSS, MOSS |
No Comments »
March 26th, 2008 . by <Patrick/>
I created a custom action that is supposed to show up in the Actions drop down of a document library but it’s not.
Here’s my code:
<?xml version=”1.0″ encoding=”utf-8″?>
<Elements Id=”745bc8db-3859-49fc-ac9d-4ebf74e1929e” xmlns=”http://schemas.microsoft.com/sharepoint/”>
<CustomAction
Id=”CheckInAll”
RegistrationType=”List”
RegistrationId=”101″
GroupId=”ActionsMenu”
Location=”Microsoft.Sharepoint.StandardMenu”
ImageUrl=”~site/_layouts/images/checkin.GIF”
Sequence=”1000″
Title=”Check In All Documents” >
<UrlAction Url=”~site/_layouts/CheckInAll.aspx?ListId={ListId}”/>
</CustomAction>
</Elements>
Here’s the code that worked:
<?xml version=”1.0″ encoding=”utf-8″?>
<Elements Id=”745bc8db-3859-49fc-ac9d-4ebf74e1929e” xmlns=”http://schemas.microsoft.com/sharepoint/”>
<CustomAction
Id=”CheckInAll”
RegistrationType=”List”
RegistrationId=”101″
GroupId=”ActionsMenu”
Location=”Microsoft.SharePoint.StandardMenu”
ImageUrl=”~site/_layouts/images/checkin.GIF”
Sequence=”1000″
Title=”Check In All Documents” >
<UrlAction Url=”~site/_layouts/CheckInAll.aspx?ListId={ListId}”/>
</CustomAction>
</Elements>
Can you spot the difference? Hint: the letter P
�
Posted in Sharepoint, WSS, MOSS |
No Comments »
February 26th, 2008 . by <Patrick/>
I love the deploy functionality built in to Visual Studio Extensions for Windows Sharepoint Services. It makes creating solution files so much easier. Creating manifest.xml files, using makecab.exe blah blah blah - what a headache! With every blog out there someone has a different way of creating it ie using ms build some third party tool from CodePlex, using .bat and .cmd files - Brutal!!
Anyways all was fine and dany I was pumping out webparts, lists, custom fields etc but then I tried deploying a custom application page and a custom action.
I created the following folder structure Template/Layouts/CustomAppPage and then put my .aspx file there but when deploying the solution VS was not copying the file to the 12 hive Layouts directory. When I checked out the WSP view my features and files were not there.
After a long time I finally realized what I was doing wrong. I first created my aspx file, feature and elements files in one project and then just copied them and added them to my new Empty Sharepoint solution.
What you need to always do is in Solution Explorer right click and then Add Item
For Application pages use the Template item for Elements.xml files use the Module item. Have Visual Studio create the files and then just copy and paste your existing code into them.
Now you should see your features in WSP view. Hit F2 to rename the the features and elements appropriately.
�
Posted in Sharepoint, WSS, MOSS, Visual Studio, VSEWSS |
No Comments »