The simple task of aligning labels and text can become not so easy when you move away from using tables. In this example I'm wrapping the lables and textboxes in div and using a bit of CSS to produce the result below. The important bits are highlighted.
div{
clear:left;
margin: 5px 0 0; padding: 1px 3px;
width: 400px;
}
.input{
display:block; float: left;
margin: 0 0 5px; padding: 3px 5px;
text-align:right;width: 130px;
}
<div>
<asp:Label AssociatedControlID="txtOne" CssClass="input" ID="label1" runat="server"
Text="Text One:"></asp:Label>
<asp:TextBox ID="txtOne" runat="server"></asp:TextBox>
</div>
<div>
<asp:Label AssociatedControlID="txtTwo" CssClass="input" ID="label2" runat="server"
Text="Text Two:"></asp:Label>
<asp:TextBox ID="txtTwo" runat="server"></asp:TextBox>
</div>
<div>
<asp:Label AssociatedControlID="ddlOne" CssClass="input" ID="label3" runat="server"
Text="DropDown:"></asp:Label>
<asp:DropDownList ID="ddlOne" runat="server">
<asp:ListItem>Choice1</asp:ListItem>
<asp:ListItem>Choice2</asp:ListItem>
</asp:DropDownList>
</div>
<div>
<asp:Label AssociatedControlID="txtThree" CssClass="input" ID="label4" runat="server"
Text="Text Three:"></asp:Label>
<asp:TextBox ID="txtThree" runat="server" Rows="5" TextMode="MultiLine"></asp:TextBox>
</div>
<div>
<asp:Label AssociatedControlID="txtFour" CssClass="input" ID="label5" runat="server"
Text="Text Four:"></asp:Label>
<asp:TextBox ID="txtFour" runat="server" Rows="5" TextMode="MultiLine"></asp:TextBox>
</div>
Sunday, October 3, 2010
Saturday, July 31, 2010
Enable IntelliSense for SharePoint Client Object Model in Visual Studio 2010
Microsoft released some guidance on enabling intellisense for the SharePoint client object model and was disappointed, it only gave partial intellisense. After a bit of investigating, I found that there are a number of debug.js files in the layouts folder. Adding the SP.Core.debug.js file gave me the result I was looking for.
<script type="text/javascript" src="/_layouts/MicrosoftAjax.js" ></script>
<script type="text/javascript" src="/_layouts/SP.debug.js" />
<script type="text/javascript" src="/_layouts/SP.Core.debug.js" />
<script type="text/javascript" src="/_layouts/SP.debug.js" />
<script type="text/javascript" src="/_layouts/SP.Core.debug.js" />
Sunday, July 25, 2010
Table of Contents Web Part
The table of contents web part isn't showing all the sites. Go to site settings, navigation and increase the number of sites to display.
Labels:
SharePoint 2010 TOC
Thursday, July 22, 2010
Windows 2008R2 boot VHD
I was in need of a faster SharePoint 2010 development environment and saw some posts on booting from a vhd and decided to give it a try. I'm running Windows 7 ultimate on my laptop and will install Windows 2008 R2 on the vhd. The first thing I tried was converting my virtualbox hard drive. Big waste of time, the conversion from vdi to vhd just didn't work. So, it was time to create a new vhd and install everything all over again. In this post I'll go thorough the steps to create a new vhd and install Windows 2008R2 on to it.
Change the bios settings on your machine so the dvd will boot before the hard drive.
Boot your machine from the install dvd. Oh, you don't have an install dvd, you have an iso file don't you? So you need to create an install dvd from the iso file. It's not so bad. Use a utility like ImgBurn to unpack the image file to disk, you'll see all the setup files when your done.
Boot your machine from the install dvd. Select your language and click next.
Go to the command prompt - enter shift+F10
x:\sources > diskpart
diskpart > create vdisk file=c:\win2008r2.vhd maximum=40000 type=expandable
diskpart > select vdisk file=c:\win2008r2.vhd
diskpart > attach vdisk
diskpart > exit
x:\sources > exit
Install the operating system - you will be able to select your new vhd later.
Select the disk you just created, there will be more than one to choose from. Choose carefully. Ignore the warning that you can't use the disk.
Continue with the installation.
When the installation is finished, remove the dvd from the drive and restart your machine. You will be able to choose between Windows 7 and Windows 2008R2.
Change the bios settings on your machine so the dvd will boot before the hard drive.
Boot your machine from the install dvd. Oh, you don't have an install dvd, you have an iso file don't you? So you need to create an install dvd from the iso file. It's not so bad. Use a utility like ImgBurn to unpack the image file to disk, you'll see all the setup files when your done.
Boot your machine from the install dvd. Select your language and click next.
Go to the command prompt - enter shift+F10
x:\sources > diskpart
diskpart > create vdisk file=c:\win2008r2.vhd maximum=40000 type=expandable
diskpart > select vdisk file=c:\win2008r2.vhd
diskpart > attach vdisk
diskpart > exit
x:\sources > exit
Install the operating system - you will be able to select your new vhd later.
Select the disk you just created, there will be more than one to choose from. Choose carefully. Ignore the warning that you can't use the disk.
Continue with the installation.
When the installation is finished, remove the dvd from the drive and restart your machine. You will be able to choose between Windows 7 and Windows 2008R2.
Saturday, June 26, 2010
Migrating to SharePoint 2010
Recently I've been migrating farms from SharePoint 2007 to 2010 using the attach database method. In this post I'm going to outline the steps I've used to perform the upgrade. I'm assuming SharePoint 2010 has been set up and that the visual compatibility mode will be used.
Clean Up Your Current Environment
Remove unused site collections, features, etc. Run "stsadm -o preupgradecheck" to identify potential problems.
Find the Customizations
Your disaster recovery plan will really come in handy here. If you don't have a disaster recovery plan, this will be a good start for one. Go to central administration and note your settings. They will need to be used to configure your new farm. Find the custom code and files that have been deployed to your farm. If solutions have been used to deploy customizations, they can be used to deploy to the new farm. Make copies of the web.config files, many of the custom settings have been made by hand. Think safe controls, http modules, application settings, connection strings. Run a comparison between your 12 hive and an oob 12 hive to find any differences. Check IIS for any folders or applications that have been added.
Copy your Content Databases
The databases can be detached and copied or backups can be taken. Copy the .mdf files to the new SQL Server.
Install Customizations to the new 2010 Farm
Install your solutions and features, move files into the 14 hive, edit the web.config files... Create new Web Applications for the ones you’re moving. Delete the configuration databases that are created.
Attach the Content Databases to the new SQL Server
Test Content Database against the Web Applications
Run Powershell command: Test-SPContentDatabase -Name "contentdbname" -WebApplication "http://webapplicationurl" This will give you the guids of missing features and let you know if there are any errors that would stop the upgrade.
Attach the Content Database to the farm
Run Powershell command: Mount-SPContentDatabase -Name "contentdbname" -WebApplication "http://webapplicationurl"
Test the upgraded farm
Clean Up Your Current Environment
Remove unused site collections, features, etc. Run "stsadm -o preupgradecheck" to identify potential problems.
Find the Customizations
Your disaster recovery plan will really come in handy here. If you don't have a disaster recovery plan, this will be a good start for one. Go to central administration and note your settings. They will need to be used to configure your new farm. Find the custom code and files that have been deployed to your farm. If solutions have been used to deploy customizations, they can be used to deploy to the new farm. Make copies of the web.config files, many of the custom settings have been made by hand. Think safe controls, http modules, application settings, connection strings. Run a comparison between your 12 hive and an oob 12 hive to find any differences. Check IIS for any folders or applications that have been added.
Copy your Content Databases
The databases can be detached and copied or backups can be taken. Copy the .mdf files to the new SQL Server.
Install Customizations to the new 2010 Farm
Install your solutions and features, move files into the 14 hive, edit the web.config files... Create new Web Applications for the ones you’re moving. Delete the configuration databases that are created.
Attach the Content Databases to the new SQL Server
Test Content Database against the Web Applications
Run Powershell command: Test-SPContentDatabase -Name "contentdbname" -WebApplication "http://webapplicationurl" This will give you the guids of missing features and let you know if there are any errors that would stop the upgrade.
Attach the Content Database to the farm
Run Powershell command: Mount-SPContentDatabase -Name "contentdbname" -WebApplication "http://webapplicationurl"
Test the upgraded farm
Wednesday, May 12, 2010
Copy DLL from GAC
From time to time you will need to copy a dll from the GAC or assembly. The easiest way I've found to copy the file is to open a command prompt and enter the following command.
SUBST M: C:\Windows\Assembly
This will create a new drive M: that you can use to copy the file.
SUBST M: C:\Windows\Assembly
This will create a new drive M: that you can use to copy the file.
Labels:
Copy Assembly GAC
Monday, May 10, 2010
Content Query Web Part - Common Enhancements
The content query web part affectionately known as CQWP is one of the go to oob SharePoint components. It's really great at rollups on content types within a site collection. The CQWP is built with xslt so this post will focus on modifications to "ItemStyle.xsl" or your own custom item style file. Be careful of white spaces and line returns when formatting the XSLT. A couple of tools that will help a great deal with the CAML and fields are U2U CAML query Builder, SharePoint Manager and SharePoint designer.
It looks like this all put together
mode="itemstyle">
<xsl:variable name="SafeLinkUrl">
<xsl:call-template name="OuterTemplate.GetSafeLink">
<xsl:with-param name="UrlColumnName" select="'LinkUrl'" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="DisplayTitle">
<xsl:call-template name="OuterTemplate.GetTitle">
<xsl:with-param name="Title" select="normalize-space(@Title)" />
<xsl:with-param name="UrlColumnName" select="'LinkUrl'" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="LinkTarget">_blank</xsl:variable>
<xsl:variable name="UniqueField" select="normalize-space(@Sorted1)" />
<xsl:variable name="CountUniqueField"
select="count(preceding-sibling::*[@*['Sorted1']=$UniqueField])" />
<xsl:variable name="HEADER">
<xsl:if test="count(preceding-sibling::*)=0">
<![CDATA[<table border="0" cellspacing="0" width="100%">
<tr>
<th>Link To Item</th>
<th>Status</th>
<th>Date</th>
</tr>
]]>
</xsl:if>
</xsl:variable>
<xsl:variable name="FOOTER">
<xsl:if test="count(following-sibling::*)=0">
<![CDATA[ </table> ]]>
</xsl:if>
</xsl:variable>
<xsl:value-of select="$HEADER" disable-output-escaping="yes"/>
<xsl:if test="$CountUniqueField < 1">
<tr>
<td class="ms-vb">
<xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>
<a href="{$SafeLinkUrl}" target="{$LinkTarget}" title="{@LinkToolTip}"
style="font-size:12px;font-weight:bold;">
<xsl:value-of select="$DisplayTitle" />
</a>
</td>
<td class="ms-vb">
<img>
<xsl:attribute name="src">
<xsl:if test="normalize-space(@status) = 'Green'">
/images/green.gif</xsl:if>
<xsl:if test="normalize-space(@status) = 'Yellow'">
/images/yellow.gif</xsl:if>
<xsl:if test="normalize-space(@status) = 'Red'">
/images/red.gif</xsl:if>
</xsl:attribute>
</img>
</td>
<td class="ms-vb">
<xsl:value-of select="ddwrt:FormatDate(string(@CDate) ,1033 ,1)"/>
</td>
</tr>
</xsl:if>
<xsl:value-of select="$FOOTER" disable-output-escaping="yes"/>
</xsl:template>
Use additional fields
First, export the webpart and open it in notepad. Edit the CommonViewFields property. The fields are formatted like this "internal name","type"; After adding the fields, save the file and import it back into the site. Test and make sure the web part still works. If not check names, types, white space and new lines.
<property name="CommonViewFields" type="string">Sorted1,Text;Status,Text;CDate,Date; </property>
Formatting Dates
Add the highlighted line to the xsl:stylesheet tag.
<xsl:stylesheet
version="1.0"
exclude-result-prefixes="x d xsl msxsl cmswrt"
xmlns:x="http://www.w3.org/2001/XMLSchema"
xmlns:d="http://schemas.microsoft.com/sharepoint/dsp"
xmlns:cmswrt="http://schemas.microsoft.com/WebParts/v3/Publishing/runtime"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime">
version="1.0"
exclude-result-prefixes="x d xsl msxsl cmswrt"
xmlns:x="http://www.w3.org/2001/XMLSchema"
xmlns:d="http://schemas.microsoft.com/sharepoint/dsp"
xmlns:cmswrt="http://schemas.microsoft.com/WebParts/v3/Publishing/runtime"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime">
You can then format the date like this.
<xsl:value-of select="ddwrt:FormatDate(string(@CDate) ,1033 ,1)"/>
Headers and Footers
There are a number of posts out there on this subject but this is what has worked for me and has been the least painful to develop. First create variables for the header and footer and then use them at the top and bottom of the template.
<xsl:variable name="HEADER">
<xsl:if test="count(preceding-sibling::*)=0">
<![CDATA[<table border="0" cellspacing="0" width="100%">
<tr>
<th>Header1</th>
<th>Header2</th>
<th>Header3</th> </tr>]]>
</xsl:if>
</xsl:variable>
<xsl:variable name="FOOTER">
<xsl:if test="count(following-sibling::*)=0">
<![CDATA[ </table> ]]>
</xsl:if>
</xsl:variable>
You can then use them like this.<xsl:if test="count(preceding-sibling::*)=0">
<![CDATA[<table border="0" cellspacing="0" width="100%">
<tr>
<th>Header1</th>
<th>Header2</th>
<th>Header3</th> </tr>]]>
</xsl:if>
</xsl:variable>
<xsl:variable name="FOOTER">
<xsl:if test="count(following-sibling::*)=0">
<![CDATA[ </table> ]]>
</xsl:if>
</xsl:variable>
<xsl:value-of select="$HEADER" disable-output-escaping="yes"/>
<xsl:value-of select="$FOOTER" disable-output-escaping="yes"/>
Only Show the Most Recent Entry
This is common requirement when rolling up status reports. This technique requires that the list items be in the correct order. To ensure that the list items are in the correct order the web part itself needs to be modified. To do this export the webpart and open it in notepad. Edit the QueryOverride property with the correct CAML statements. Save the changes and import the web part. (Any valid CAML can be placed in the QueryOverride tag.)
<property name="QueryOverride" type="string"><![CDATA[<OrderBy><FieldRef Name="Sorted1" Ascending="True"/><FieldRef Name="CDate" Ascending="False"/></OrderBy>]]></property>
Now that the data is in the correct order, only show the first record. First create a variable that contains the value of the unique field. Then use the variable to get a count of records before the current record that contains the unique value.
<xsl:variable name="UniqueField" select="normalize-space(@Sorted1)" />
<xsl:variable name="CountUniqueField"
select="count(preceding-sibling::*[@*['Sorted1']=$UniqueField])" />
Wrap your detail html with the following if statement.<xsl:variable name="CountUniqueField"
select="count(preceding-sibling::*[@*['Sorted1']=$UniqueField])" />
<xsl:if test="$CountUniqueField < 1">
<!-- Your xslt & html here ---></xsl:if>
Format as KPI/Stop Light/Green Yellow Red
Here the status field is compared to green/yellow/red and the src attribute of the <img> tag is set appropriately.
<img>
<xsl:attribute name="src">
<xsl:if test="normalize-space(@status) = 'Green'">/images/green.gif</xsl:if>
<xsl:if test="normalize-space(@status) = 'Yellow'">/images/yellow.gif</xsl:if>
<xsl:if test="normalize-space(@status) = 'Red'">/images/red.gif</xsl:if>
</xsl:attribute>
</img>
<xsl:attribute name="src">
<xsl:if test="normalize-space(@status) = 'Green'">/images/green.gif</xsl:if>
<xsl:if test="normalize-space(@status) = 'Yellow'">/images/yellow.gif</xsl:if>
<xsl:if test="normalize-space(@status) = 'Red'">/images/red.gif</xsl:if>
</xsl:attribute>
</img>
It looks like this all put together
<xsl:template name="CustomItemStyle" match="Row[@Style='CustomItemStyle']"
mode="itemstyle">
<xsl:variable name="SafeLinkUrl">
<xsl:call-template name="OuterTemplate.GetSafeLink">
<xsl:with-param name="UrlColumnName" select="'LinkUrl'" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="DisplayTitle">
<xsl:call-template name="OuterTemplate.GetTitle">
<xsl:with-param name="Title" select="normalize-space(@Title)" />
<xsl:with-param name="UrlColumnName" select="'LinkUrl'" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="LinkTarget">_blank</xsl:variable>
<xsl:variable name="UniqueField" select="normalize-space(@Sorted1)" />
<xsl:variable name="CountUniqueField"
select="count(preceding-sibling::*[@*['Sorted1']=$UniqueField])" />
<xsl:variable name="HEADER">
<xsl:if test="count(preceding-sibling::*)=0">
<![CDATA[<table border="0" cellspacing="0" width="100%">
<tr>
<th>Link To Item</th>
<th>Status</th>
<th>Date</th>
</tr>
]]>
</xsl:if>
</xsl:variable>
<xsl:variable name="FOOTER">
<xsl:if test="count(following-sibling::*)=0">
<![CDATA[ </table> ]]>
</xsl:if>
</xsl:variable>
<xsl:value-of select="$HEADER" disable-output-escaping="yes"/>
<xsl:if test="$CountUniqueField < 1">
<tr>
<td class="ms-vb">
<xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>
<a href="{$SafeLinkUrl}" target="{$LinkTarget}" title="{@LinkToolTip}"
style="font-size:12px;font-weight:bold;">
<xsl:value-of select="$DisplayTitle" />
</a>
</td>
<td class="ms-vb">
<img>
<xsl:attribute name="src">
<xsl:if test="normalize-space(@status) = 'Green'">
/images/green.gif</xsl:if>
<xsl:if test="normalize-space(@status) = 'Yellow'">
/images/yellow.gif</xsl:if>
<xsl:if test="normalize-space(@status) = 'Red'">
/images/red.gif</xsl:if>
</xsl:attribute>
</img>
</td>
<td class="ms-vb">
<xsl:value-of select="ddwrt:FormatDate(string(@CDate) ,1033 ,1)"/>
</td>
</tr>
</xsl:if>
<xsl:value-of select="$FOOTER" disable-output-escaping="yes"/>
</xsl:template>
Subscribe to:
Posts (Atom)


