Friday, February 29, 2008

How to hide View: menu on the right-hand-side of the SharePoint 2007 toolbar?

  • Display the view in a browser
  • Open the source in an editor. This is done by "right-click / view source" in IE
  • Search for "ms-listheaderlabel". It will land on a <td> tag.
  • Right under that <td> tag you will find another <td> tag with an ID like: ctl00_m_g_672c28cb_9a7b_4898_a26c_22eefe71074d_ctl00_ctl00_toolBarTbl_RightRptControls_ctl00_ctl00_onetViewSelector
  • Copy the ID into the clipboard.
  • Create a style in an editor as follows and use the ID that you copied into the clipboard:

<style type="text/css">

 
#ctl00_m_g_672c28cb_9a7b_4898_a26c_22eefe71074d_ctl00_ctl00_toolBarTbl_RightRptControls_ctl00_ctl00_onetViewSelector{

visibility:hidden;

}

.ms-listheaderlabel {

visibility:hidden;

}

 

</style>
  • Click on "Site Actions / Edit Page"
  • Add "Content Editor Web Part" to the page.
  • Cick on "open the tool pane"
  • Click on the "Source Editor ..." button on the far right-hand-side of the page
  • Copy and paste the <script ...> code from your editor into the "Text Entry -- Webpage Dialog"
  • Click "Save" button
  • Click "OK" button
  • Click "Exit Edit Mode" link.

Tuesday, February 19, 2008

DevTeach 2008 Toronto

Yes. I will be delivering three talks on SharePoint at the DevTeach 2008 conference in Toronto May 12-16 2008. I am thrilled to be invited once again after DevTeach Vancouver in November 2007. Check out the conference at http://www.devteach.com/.
My presentations are:

SharePoint 101

SharePoint 2007 Advanced Development

WebParts for SharePoint 2007

Wednesday, February 13, 2008

How to enable session state in SharePoint WSS 3.0?

Before you can use sessions you first have to enable the session state module in the web.config file in a WSS 3.0 sharepoint site. Just uncomment the following line:


<!—
<add name="Session" type="System.Web.SessionState.SessionStateModule"/>
-->

After that you can use the session object like you'll normally do with any ASP.NET web applications.

Sunday, January 13, 2008

How can a web page go to the bottom end as soon as it is loaded?

I needed to get a loaded web page to scroll down to the bottom of a long page. I was able to make that happen using some basic JavaScript. Here's my solution:


1) Place the following HTML at the page loaction where you want to go to automatically:

<a id="bottom" name="bottom"></a>

2) Add the following ASP.NET code that triggers some very basic JavaScript:

StringBuilder sb = new StringBuilder();

sb.Append("<script language='javascript' >");

sb.Append("window.location.href = '#bottom';");

sb.Append("</script>");

ClientScript.RegisterStartupScript(typeof(Page), "Focus", sb.ToString());

Although thic technique pertains to ASP.NET 2.0, it really can be implemented in any other server-side technology.

Thursday, January 3, 2008

Unable to delete or customize a choice field in WSS 3.0

I needed to customize the HelpDesk template that is freely downloadable from Microsoft. I discovered that it is not possible to add any choice items or even delete the column. Here's what I experienced when I clicked on:
Service Requests ==> Site Settings ==> List Settings ==> Status

You will notice that the "Delete" button is missing and no choice items can be changed.
I discovered that the choice field is sealed in the feature template itself.

Solution:

1) Open the schema.xml file located in the SharePoint 2007 12-hives directory at:

%ProgramFiles%\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\HelpDeskServiceRequestsList\servicerequest

2) Search for the Status field.

<Field ID="{75AF1E7D-39F1-45db-908A-B7AD3F26531A}"

Type="Choice"

Name="Status"

DisplayName="$Resources:hlpdsk,SRStatus;"

StaticName="Status"

Required="TRUE"

Sealed="TRUE"

Format="Dropdown"

FillInChoice="FALSE"

SourceID="http://schemas.microsoft.com/sharepoint/v3"

>

<Default>$Resources:hlpdsk,SRStatus_Choice1;</Default>

<CHOICES>

<CHOICE>$Resources:hlpdsk,SRStatus_Choice1;</CHOICE>

<CHOICE>$Resources:hlpdsk,SRStatus_Choice2;</CHOICE>

<CHOICE>$Resources:hlpdsk,SRStatus_Choice3;</CHOICE>

<CHOICE>$Resources:hlpdsk,SRStatus_Choice4;</CHOICE>

</CHOICES>

</Field>

3) Change the Sealed attribute value from TRUE to FALSE

4) Save the schema.xml file

5) Restart IIS

Friday, December 28, 2007

Presentation on SharePoint WebParts to Bellingham .NET Users Group

Andrew Robinson, the president of the Bellingham .NET Users Group, invited me to give a talk to his group. I will be giving them a talk on "WebParts for SharePoint 2007" on Wednesday January 8, 2007 starting at 6:00 PM. Bellingham is the most visited city accross the border for British Columbians and I look forward to forging closer ties between .netBC and the Bellingham .NET Users Groups.
Here is the extract of my talk:
WebParts for SharePoint 2007

WebParts provide the fundamental building blocks for creating custom applications for SharePoint. This session will show you how to efficiently and quickly use your ASP.NET 2.0 and C# skills to develop WebParts for deployment into SharePoint 2007. Most of the development, testing and debugging will be done in Visual Studio .NET 2007. We shall then deploy the WebPart as a feature into Windows SharePoint Services 3.0 (WSS 3.0). We will also look at WebPart communication and modifying WebPart verb menus.

Wednesday January 9, 2008

The files that make up my presentation can be downloaded from here.

Thursday January 10, 2008

I had an enjoyable time at Bellingham. There were 13 people in attendance. Pizza was great and I was glad that they serve water instead of the dreaded pop.

Wednesday, December 19, 2007

Move SharePoint 2007 paging control from the right to the left of the action bar.



A user at my workplace has a view that is horizontally very wide. It drives him nuts to have to scroll all the way to the extreme right of the page in order to find the paging control. He pleaded with me to find a way to move this control to the left side of the action bar. After many hours of research, here's what I found:

The default layout of the action bar is defined in a user control file named DefaultTemplates.ascx found in the TEMPLATE\CONTROL TEMPLATES directory of your 12-hives

The default layout can be alterted for a particular type of list be over-riding the "ViewToolBar" for that list.

This is best done by working on a copy of DefaultTemplates.ascx

I moved the paging control for the DocumentLibraryViewToolBar to the left-hand-side by doing the following:



copy DefaultTemplates.ascx to PagingLeftOnDocLibrary.ascx (or any other name you fancy).

open PagingLeftOnDocLibrary.ascx in a text editor

search for DocumentLibraryViewToolBar. Your editor should find this line: <SharePoint:RenderingTemplate ID="DocumentLibraryViewToolBar" runat="server">

delete all <SharePoint:RenderingTemplate>.. </SharePoint:RenderingTemplate> sections before and after the section that you have just found. In other words retain the section <SharePoint:RenderingTemplate ID="DocumentLibraryViewToolBar" runat="server"> .. </SharePoint:RenderingTemplate> and delete all other sections

You will be left with only the following:

<%@ Control Language="C#" AutoEventWireup="false" %>

<%@Assembly Name="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<%@Register TagPrefix="SharePoint" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" namespace="Microsoft.SharePoint.WebControls"%>

<%@Register TagPrefix="SPHttpUtility" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" namespace="Microsoft.SharePoint.Utilities"%>

<%@ Register TagPrefix="wssuc" TagName="ToolBar" src="~/_controltemplates/ToolBar.ascx" %>

<%@ Register TagPrefix="wssuc" TagName="ToolBarButton" src="~/_controltemplates/ToolBarButton.ascx" %>

<SharePoint:RenderingTemplate ID="DocumentLibraryViewToolBar" runat="server">

<Template>

<wssuc:ToolBar

CssClass="ms-menutoolbar"

EnableViewState="false"

id="toolBarTbl"

ButtonSeparator="<img src='/_layouts/images/blank.gif'

alt=''>" RightButtonSeparator="  "

runat="server">

<Template_Buttons>

<SharePoint:NewMenu AccessKey="<%$Resources:wss,tb_NewMenu_AK%>" runat="server"/>

<SharePoint:UploadMenu AccessKey="<%$Resources:wss,tb_UploadMenu_AK%>" runat="server"/>

<SharePoint:ActionsMenu AccessKey="<%$Resources:wss,tb_ActionsMenu_AK%>" runat="server"/>

<SharePoint:SettingsMenu AccessKey="<%$Resources:wss,tb_SettingsMenu_AK%>" runat="server"/>

</Template_Buttons>

<Template_RightButtons>

<SharePoint:PagingButton runat="server"/>

<SharePoint:ListViewSelector runat="server"/>

</Template_RightButtons>

</wssuc:ToolBar>

</Template>

</SharePoint:RenderingTemplate>

The PagingButton section (shown in red above) needs to be moved to the Template_Buttons section. I simply cut <SharePoint:PagingButton runat="server"/> and pasted it right before </Template_Buttons>

If you restart IIS (IISRESET from the command line) you should see the paging control on the left-hand-side of the document library action bar as shown below.


The final version of my PagingLeftOnDocLibrary.ascx is:

<%@ Control Language="C#" AutoEventWireup="false" %>

<%@Assembly Name="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<%@Register TagPrefix="SharePoint" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" namespace="Microsoft.SharePoint.WebControls"%>

<%@Register TagPrefix="SPHttpUtility" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" namespace="Microsoft.SharePoint.Utilities"%>

<%@ Register TagPrefix="wssuc" TagName="ToolBar" src="~/_controltemplates/ToolBar.ascx" %>

<%@ Register TagPrefix="wssuc" TagName="ToolBarButton" src="~/_controltemplates/ToolBarButton.ascx" %>

<SharePoint:RenderingTemplate ID="DocumentLibraryViewToolBar" runat="server">

<Template>

<wssuc:ToolBar

CssClass="ms-menutoolbar"

EnableViewState="false"

id="toolBarTbl"

ButtonSeparator="<img src='/_layouts/images/blank.gif'

alt=''>" RightButtonSeparator="  "

runat="server">

<Template_Buttons>

<SharePoint:NewMenu AccessKey="<%$Resources:wss,tb_NewMenu_AK%>" runat="server"/>

<SharePoint:UploadMenu AccessKey="<%$Resources:wss,tb_UploadMenu_AK%>" runat="server"/>

<SharePoint:ActionsMenu AccessKey="<%$Resources:wss,tb_ActionsMenu_AK%>" runat="server"/>

<SharePoint:SettingsMenu AccessKey="<%$Resources:wss,tb_SettingsMenu_AK%>" runat="server"/>

<SharePoint:PagingButton runat="server"/>

</Template_Buttons>

<Template_RightButtons>

<SharePoint:ListViewSelector runat="server"/>

</Template_RightButtons>

</wssuc:ToolBar>

</Template>

</SharePoint:RenderingTemplate>