3/21/2009

SharePoint: Site Title - Change the Font Size, Face or Hide It

 

Just some more little CSS and CEWP tricks…

 

Hiding the title

If you have replaced the site icon (Site Action, Site Settings, Title Description and Icon) with a large banner image you will probably want to get rid of site title.

You could just go into Site Settings and delete the title, but that cause problems down the road with search and site navigation (crumb trail, etc). Better, just make it disappear. Just use this fragment of CSS:

    <style type="text/css">
      .ms-sitetitle h1 
     {
        display:none
     }
    </style>

Note: the “h1" is needed so you also don’t hide the table cell containing the title.

You can either put this in your masterpage just below the SharePoint:CssLink and SharePoint:Theme tags and this will hide the title for all pages in the site (except for application pages which have their own masterpage).

Or… you can put the CSS in a Content Editor Web Part (CEWP). Add the CEWP, edit the properties and click the Source Editor button. Add your CSS and save. This would need to be repeated for each page in the site.

 

Changing the title size or font:

Big site icon and just a little site title? To fix just add this CSS:

    <style type="text/css">
      .ms-sitetitle a 
      {
        font-size:48pt;
        color:blue;
        font-family:"Comic Sans MS"
      }
    </style>

Note: the “a” is needed as the title is enclosed in an anchor “<A>” tag.

Again, you can put the CSS in either the masterpage or in a Content Editor Web Part.

 

Using a Content Editor Web Part

Note that using a CEWP will only update the page with the web part. To update the site title on all pages in your site you will need to add the CSS to the master page.

  • Add a Content Editor web part:

    • Edit Page (from ribbon, Site Actions, etc. depending on the versoin) 
    • Add a Content Editor web part (using the ribbon or web part zone buttons)
    • Click in the web part, click Edit, Modify Shared Web Part, and in the Appearance section change "Chrome" to "None".
  • Add the CSS:

    • Click the Source Editor button
    • Type or paste the CSS

    .

  • 3/15/2009

    SharePoint: One library, multiple sites!

    Update:

    I finally got around to testing this in SharePoint 2010, and it works!  Every once and a while I got an error message when saving the page after adding the web part, but it was random and I could not duplicate it. If you try this in 2010, then please add a comment to this article and share if it worked or not.

     

    Article summary:

    • I will show how to create a custom web part that represents a list or library’s view and use this web part in other sites (at least in the same site collection) without copying documents between sites.
    • This custom web part supports a tool bar so files can be uploaded and maintained in a single library, but viewed and maintained from any site in the site collection that has this web part.
    • Tools needed:
      • SharePoint Designer (to make one quick change, export the web part, and then optionally roll back the change)
      • Some way to find the site’s GUID (see link to a tool below)

    The Question:

    What started out as a simple question has led to some interesting results. So interesting that someone somewhere else must have written this up. I’ve not found it, so here goes…

    The question that started this was “why don’t list and library web parts have a ‘Export’ option?” Most other web parts do.

    First some observations:

    • While editing a web part page, click a web part’s menu and you will usually see an Export option, except for list and library web parts.
    • List and library view pages are web part pages (they have “Edit Page” in the Site Actions menu") and the displayed list is a web part.

    So how can you export a list web part?

    Turns out to be pretty easy. Edit the page in SharePoint Designer and change one word.

    1. Open the site in SharePoint Designer and double click on a page with the web part (default.aspx, Shared Documents/Forms/Allitems.aspx, etc)
    2. In the code view find the web part and find
      <ExportControlledProperties>false</ExportControlledProperties>
      and change from “false” to “true”
    3. Save the page (this will “unghost” the page, but you can undo the changes after the export is complete – right-click the file in the Folder List and select Reset to Site Definition)
    4. Go to a browser and visit this page. Go to Site Actions, Edit Page.
    5. Click Edit in web part you just modified and click Export.
    6. Give the file a name and save it somewhere where you can find it in the next step.

    To import the exported settings as a new web part:

    1. Visit your top level site in the site collection and go to Site Actions, Site Settings, and in the Galleries column click Web Parts

    To add the web part.

    1. Nothing special here. Add this web part just like any other web part.

    Some differences…

    Oddly, the displayed columns are different. The AllItems view displayed Type, Name, Modified and Modified By. The new web part displays Type, Name and Modified By. This is easy to fix. Edit the web part and change the Selected View property to All Documents then you will get the same list of columns in both displays.

    The new web part does not display a toolbar by default, but this can be enabled from the web part’s properties panel. If the toolbar is enabled you will see all of the buttons found in the AllItems page, New, Upload, Actions and Settings (depending on the current user’s security rights).

     

    Now test the web part in a sub site….

    Error!

        Unable to add selected web part(s).
        List does not exist.
        The page you selected contains a list that does not exist.

    On the first attempt it appears that the new exported web part will not work on another site. Time for more research…

     

    Find the missing GUID

    Open the .DWP (.WEBPART in 2010) file created by the Export. Find these two lines:

    SP 2007
       <ListName …..>{ list_guid_here } </ListName>
       <WebId ….> all_zeros_guid_here </WebId>

    SP 2010

       <property name="ListName" type="string">{ list_guid_here } </property>
       …
       <property name="WebId" …>all_zeros_guid_here </property>

     

    SharePoint uses Globally Unique IDs (GUIDS) to identify just about everything stored in the databases. Notice that the ListName has a GUID, but the WebId is all zeros. Replace the zeros with the GUID for the site that owns the list and all will then work.

     

    How to find a GUID

    I can’t find any place in the the pages exposed in SharePoint Designer where the web site’s GUID is used, although the list’s GUID can be found in some of the URLs (for example after clicking Settings, List or Library Settings). I wrote two little utilities to display a site’s GUIDs, one a Windows application and the other a page you can deploy to the LAYOUTS folder on the server.

    See: http://techtrainingnotes.blogspot.com/2009/03/sharepoint-finding-sharepoint-guids.html

    Quick note: Internally a site is call a “web” and a site collection is called a “site”. (go figure…) The utilities above use the web and site names.

     

    Update the web part file

    Edit the WebId element and replace the all zeros GUID with the site’s GUID:

      SP 2007”   <WebId ….> all_zeros_guid_here </WebId>

      SP 2010    <property name="WebId" …>all_zeros_guid_here </property>

    After updating the DWP file with the site’s (web’s) GUID, re-upload it to the web part gallery and go and test the web part in a sub site.


    And for the “Strange Things” list… the GUID for the web site does not include brackets ( { } ) and is in lower case. The GUID for the list must have brackets and MUST be in UPPER CASE or it will not work.

     

     

    Watch outs and warnings!

    • This has not been tested in a production environment – you are on your own! (Please let me know if it works or does not work for you)
    • So far I have only tested this on MOSS 2007 Enterprise and SharePoint Server 2010, but it should work in WSS and SharePoint Foundation.
    • I have tested this so far with document libraries and several lists such as Announcements, but not with every list and library.
    • This will only work within the same site, or within the same site collection. It will not work between site collections, between applications or between servers.
    • The view displayed in the web part is a copy of the view in the original list or library. Use Edit, Modify Shared Web Part to pick another view or to refresh the view.
    • Users will need rights to the original list or library. This web part is only a view of the real list.
    • Alerts will be stored in the site with the original list so alert management will need to be done from that site’s Site Actions, Site Settings menu.
    • Most menu options will display screens from the site with the original list, but when the user clicks OK, Cancel, Close, etc, they will return to the site with the web part. One exception is if an operation generates as error, the “Go back to site” link will take them to the list’s site, not the web part’s site.
    • Batteries not included, your mileage may vary…

     

    Have fun, and let me know if this works or does not work for you.

     

    .

    3/14/2009

    SharePoint: Finding SharePoint GUIDs

     

    Update… I put together a PowerShell version of this here: http://techtrainingnotes.blogspot.com/2011/06/finding-sharepoint-guids-using.html  (so now you have four versions!)

    Update… I put together a version of this that uses the SharePoint web services so you can get the GUIDs without having to be on the server. The EXE and the C# project can be downloaded here.

    So now you have three versions, API from a Windows app, API from a LAYOUTs page and Web Services from a Windows app.

    ---

     

     

    Just a little code to share….   :-)

     

    I needed a quick way to find the GUIDs used on a SharePoint site so I wrote a little C# routine to display them. Below is the sample code for both a Windows app and a SharePoint Layouts ASPX page.

     

    The Windows Version:

    As this calls the API instead of the web services so this will need to be run from one of the SharePoint servers.

    Add a textbox, a button and a listbox on a form then…

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using Microsoft.SharePoint;

    namespace WindowsApplication2
    {
        public partial class Form1 : Form
        {
            public Form1()
            {  InitializeComponent();    }

            private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
            {
                textBox1.Text = listBox1.SelectedItem.ToString();
            }

            private void button1_Click(object sender, EventArgs e)
            {
                listBox1.Items.Clear();
                SPSite site;
                try
                {
                    site = new SPSite(txtSiteURL.Text);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
                listBox1.Items.Add("Site: " + site.ID.ToString());
                SPWeb web = SPContext.Current.Web;  //site.RootWeb;
                listBox1.Items.Add("Web: " + web.ID.ToString());
                foreach (SPList list in web.Lists)
                {
                    listBox1.Items.Add(list.Title + ": " + list.ID.ToString());
                }

            }

        }
    }

     

    The Layouts folder version:

    Create a text file in the SharePoint LAYOUTS folder with a name like “getGuids.aspx” and paste the following code. Run the page from any site:  http://youserver/yoursite/_layouts/getGuids.aspx

    <%@ Page Language="C#"  %>
    <%@ Import Namespace="Microsoft.SharePoint" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <script runat="server">
        private void Page_Load(object sender, EventArgs e)
        {
            ListBox1.Items.Clear();
            SPSite site;
            site = SPContext.Current.Site;
            ListBox1.Items.Add("Site: " + site.ID.ToString());
            SPWeb web = SPContext.Current.Web;   // site.RootWeb;
            ListBox1.Items.Add("Web: " + web.ID.ToString());
            foreach (SPList list in web.Lists)
            {
                ListBox1.Items.Add(list.Title + ": " + list.ID.ToString());
            }
        }

        private void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            TextBox1.Text = Request.Form["ListBox1"];
        }

    </script>

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head id="Head1" runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:TextBox ID="TextBox1" runat="server" Width="530px" />
            <br /><br />
            Click to copy to the text box.<br />
            <asp:ListBox ID="ListBox1" runat="server"
              OnSelectedIndexChanged="ListBox1_SelectedIndexChanged"
              Rows="20" AutoPostBack="True"/></div>
        </form>
    </body>
    </html>

    3/04/2009

    SharePoint: Past Due / Late Tasks in a Task List

     

    Update: If you have users who display dates in formats other than MM/DD/YYYY you will find that the following will not work consistently. Here’s is some background on the date problem in SharePoint and JavaScript and how to fix it: http://techtrainingnotes.blogspot.com/2011/03/sharepoint-javascript-and-dates.html (includes replacement code for this article)

     

    The code below and in the above link works with both SharePoint 2007 and 2010.

     

    Here’s another JavaScript trick to deal with a common request, highlighting past due tasks in a SharePoint Task List.

    Here’s a few non-JavaScript ways that this has been done:

    • Create a custom workflow (too much work and not portable, but it can also send reminder emails!)
    • Use a trick to add a calculated field using [Today] (only works when the trick is reapplied every day or each task is manually edited)

    This example uses a bit of copy-and-paste JavaScript and requires the following:

    • A Content Editor Web Part to hold the JavaScript
    • Some JavaScript you can copy from below
    • An extra column to hold the past due message (optional)

    The goal:

     

    To add the extra column:

    If you would like to display a message such as “Past Due” or display an image then you will need an extra column, preferably one your users cannot edit. A calculated column that displays a blank will do this.

    • Add a new column to your list (Settings, New Column)
    • Give it a title (any will do) such as “Past Due”
    • Make the column a Calculated column and set the formula to ="" (and equal sign followed by two quotes)

    To add the Content Editor web part and JavaScript:

    • Display the task list view to color code (each view will need its own web part and JavaScript)
    • Add a Content Editor web part
      • Site Actions, Edit Page
      • Add a Content Editor web part and move it below the calendar web part
      • In the web part, click Edit, Modify Shared Web Part, and in the Appearance section change "Chrome" to "None".
    • Add the JavaScript
      • Click the Source Editor button
      • Type or paste the JavaScript (examples below)
      • Count the columns displayed in your task list to find the “Due Date” and “Past Due” columns. The Attachments column is column zero and the Due Date is typically column five (0,1,2,3,4,5).
      • Edit the JavaScript to set these two numbers:
        var colDueDate = 5;
        var colPastDue = 7; // set to -1 to ignore
      • Click Save, OK and Exit Edit Mode to see the results
      • If you would like to display an image in place of the text change this line:

        x[i].parentNode.childNodes[colPastDue].innerHTML='Past due!'

        to:

        x[i].parentNode.childNodes[colPastDue].innerHTML='<img src="/_layouts/images/ERRLG.GIF" />'

        and set your SRC to an image in your library or in the SharePoint install folder (“images”).

    Making this work in views other than “All Tasks”

    You probably will first test this in the “All Tasks” view and then switch to one of the other task views and mumble something about Mike’s hacks don’t work everywhere!

    Well… each view page is, well… it’s own page. Check the URLs.

    All Tasks: http://…../AllItems.aspx
    Active Tasks: http://…../active.aspx
    My Tasks: http://……/MyItems.aspx

    Each page will need it’s own Content Editor Web Part with the JavaScript, the extra column will need to be displayed and the column numbers in the JavaScript adjusted.

    As an example, here are the steps for the “Active Tasks” view:

    • Modify the view to display the “Past Due” column
    • Check your column numbers for the “Due Date” and “Past Due” columns
    • Add the Content Editor Web Part and the JavaScript as described above, adjusting the column numbers as needed.

    Bugs? Issues?

    • You cannot sort the “Past Due” column as this data is not in SharePoint. It has only been added in the user’s browser. (Another plus for a workflow solution?)
    • Each new view created will need the CEWP and the JavaScript added.
    • Changing or reordering the columns in a view will require an update to the column numbers in the JavaScript.
    • As the CEWP is not visible, you will probably forget that it is there, and then wonder why the color highlighting no longer works after you modify the view!
    • As the CEWP is not visible, the next person to inherit your SharePoint site will have no idea how this works. (You do document everything you do in your site, right?)

    The JavaScript:

    <script type="text/javascript" language="javascript">

      // Stolen from techtrainingnotes.blogspot.com !

      // this routine needs to know:
      // column with the Due Date (attachment column is #0)
      //      (in the default task list Due Date is #5)
      // optional column to display the "past due" message
      //      (can be any "single line of text" column)
      var colDueDate = 5;
      var colPastDue = 7; // set to -1 to ignore

      var i=0;
      d=new Date() //current date/time

      var x = document.getElementsByTagName("TD") // find all of the TDs
      for (i=0;i<x.length;i++)
      {
        if (x[i].className=="ms-vb2") //find the TDs styled for lists
        {
          //find a row with a key phrase
          if (x[i].innerHTML=="Not Started"
               | x[i].innerHTML=="In Progress"
               | x[i].innerHTML=="Waiting on someone else" )
          {
            if (d.getTime() >= Date.parse(x[i].parentNode.childNodes[colDueDate].childNodes[0].innerHTML) )
            {
            x[i].parentNode.style.backgroundColor='red'; // set the color
            if (colPastDue > -1)
            x[i].parentNode.childNodes[colPastDue].innerHTML='Past due!' 
            }

          }

        }

      }
    </script>

    2/22/2009

    SharePoint: Annotated Minimal Master Page

    Yet another minimal master page!

    There are a number of “minimal master pages” on the web:

    I created this one for my SharePoint Designer class to both highlight the sections (the <h3> tags) and to document optional vs. required sections.

     

    You can download this file from here.

    <!-- Optional DOCTYPE -->
    <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>

    <!-- Tags needed by SharePoint and ASP.Net -->
    <%@Master language="C#"%>
    <%@ 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" %> <%@ Import Namespace="Microsoft.SharePoint" %>
    <%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
    <%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register TagPrefix="wssuc" TagName="Welcome" src="~/_controltemplates/Welcome.ascx" %>
    <%@ Register TagPrefix="wssuc" TagName="DesignModeConsole" src="~/_controltemplates/DesignModeConsole.ascx" %>

    <!-- Standard HTML tag with optional text direction "dir=" (Left to Right vs Right to Left for multilingual sites - More info: http://www.w3.org/TR/REC-html40/struct/dirlang.html#h-8.2 -->
    <HTML dir="<%$Resources:wss,multipages_direction_dir_value%>" runat="server" xmlns:o="urn:schemas-microsoft-com:office:office" __expr-val-dir="ltr">

    <HEAD runat="server">

            <!-- common meta tags - optional, but you should at least keep the "Expires" to control browser caching -->
        <META Name="GENERATOR" Content="Microsoft SharePoint">
        <META Name="progid" Content="SharePoint.WebPartPage.Document">
        <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
        <META HTTP-EQUIV="Expires" content="0">

        <!-- optional - generates this: <META NAME="ROBOTS" CONTENT="NOHTMLINDEX"/> based on options set in Site Actions, Site Settings, Search Visibility -->
        <SharePoint:RobotsMetaTag runat="server"/>

            <!-- Page title as supplied from the content page's ASP:Content tag -->       
        <Title ID=onetidTitle>
            <asp:ContentPlaceHolder id=PlaceHolderPageTitle runat="server"/>
        </Title>

            <!-- these two tags are found in non-publishing sites and load the CSS in the expected order -->
                <!-- this loads CORE.CSS and is not need if you are creating your own CSS -->
                <Sharepoint:CssLink runat="server"/>
                <!-- this loads the theme select by the user in Site Settings and is not need if you are creating your own CSS -->
                <SharePoint:Theme runat="server"/>
                <!-- your CSS links can go here -->
                <!-- <link rel="stylesheet" type="text/css" href="yourstylesheet" /> -->
            <!-- A publishing master page uses both Sharepoint.CssLink and SsharePoint:CssRegistration controls
                to load style sheets.
              Note: The CssLink control will render all of the CssRegistration CSS files in alphabetical order (!)
                    and then follow with CORE.CSS - This might not be what you expected!   
            -->

        <!-- Renders a link to a JavaScript library used by SharePoint -->
        <SharePoint:ScriptLink language="javascript" name="core.js" Defer="true" runat="server"/>
        <!-- Renders a link to a custom JavaScript URL defined in onet.xml (if present) -->
        <SharePoint:CustomJSUrl runat="server"/>
        <!-- optional - Renders path to .disco file for clients like VS2005 to discover web services on the server -->
        <SharePoint:SoapDiscoveryLink runat="server"/>
        <!-- this lets content pages load additional style sheets, javascript, meta tags etc -->
        <asp:ContentPlaceHolder id="PlaceHolderAdditionalPageHead" runat="server">
        </asp:ContentPlaceHolder>

        <!-- optional this lets installed "Features" load additional style sheets, javascript, meta tags etc -->
        <SharePoint:DelegateControl runat="server" ControlId="AdditionalPageHead" AllowMultipleControls="true"/>

    </HEAD>

    <!-- the onload runs javascript needed for master pages - scroll is optional -->
    <BODY scroll="yes" onload="javascript:if (typeof(_spBodyOnLoadWrapper) != 'undefined') _spBodyOnLoadWrapper();">

        <!-- form required for all ASPX pages -->
        <form runat="server" onsubmit="return _spFormOnSubmitWrapper();">

            <!-- required to support web parts -->
            <WebPartPages:SPWebPartManager id="m" runat="Server"/>

    <h3>Typical top of page items</h3>
            <asp:ContentPlaceHolder id="PlaceHolderGlobalNavigation" runat="server">
            <!-- common controls for the top of a site -->
                <!-- global breadcrumb trail -->
                <asp:ContentPlaceHolder id="PlaceHolderGlobalNavigationSiteMap" runat="server">
                    <asp:SiteMapPath SiteMapProvider="SPSiteMapProvider" id="GlobalNavigationSiteMap" RenderCurrentNodeAsLink="true" SkipLinkText="" NodeStyle-CssClass="ms-sitemapdirectional" runat="server"/>
                </asp:ContentPlaceHolder>
                <!-- optional - renders the variations link -->
                <SharePoint:DelegateControl runat="server" ControlId="GlobalSiteLink0"/>
                <!-- optional - renders the MySite link -->
                <SharePoint:DelegateControl ControlId="GlobalSiteLink1" Scope="Farm" runat="server"/>
                <!-- optional - renders the MyLinks menu -->
                <SharePoint:DelegateControl ControlId="GlobalSiteLink2" Scope="Farm" runat="server"/>
                <!-- optional - renders the Welcome menu -->
                <wssuc:Welcome id="explitLogout" runat="server"/>
                <!-- optional help button -->
                <a href="javascript:TopHelpButtonClick('NavBarHelpHome')" AccessKey="<%$Resources:wss,multipages_helplink_accesskey%>" id="TopHelpLink" title="<%$Resources:wss,multipages_helplinkalt_text%>" runat="server">
                <img align='absmiddle' border=0 src="/_layouts/images/helpicon.gif" alt="<%$Resources:wss,multipages_helplinkalt_text%>" runat="server">
                </a>
            &nbsp;&nbsp;&nbsp;&nbsp;</asp:ContentPlaceHolder>

    <hr>
    <h3>Typical top of page site / page header items - Site Logo, Title etc.</h3>

            <!-- Typical Site Header items - Title, Logo, etc -->

            <!-- optional - site logo from Site Settings -->
            <SharePoint:SiteLogoImage id="onetidHeadbnnr0" LogoImageUrl="/_layouts/images/titlegraphic.gif" runat="server"/>

            <!-- site title from site settings - place holder is required, SPLinkButton and ProjectProperty are optional  -->   
            <asp:ContentPlaceHolder id="PlaceHolderSiteName" runat="server">
                <SharePoint:SPLinkButton runat="server" NavigateUrl="~site/" id="onetidProjectPropertyTitle">
                    <SharePoint:ProjectProperty Property="Title" runat="server" />
                </SharePoint:SPLinkButton>
            </asp:ContentPlaceHolder>

    <hr>
    <h3>Search controls</h3>

            <!-- Search controls - placeholder is required -->
            <asp:ContentPlaceHolder id="PlaceHolderSearchArea" runat="server">
                <!-- optional - default content for search - actual search depends on content page and / or Site Settings, Search Settings (to turn on advanced search)-->
                <SharePoint:DelegateControl runat="server" ControlId="SmallSearchInputBox"/>
            </asp:ContentPlaceHolder>

    <!-- ------------------------------------------   -->

        <!-- required placeholder - this typically wraps the entire top navigation -->
        <asp:ContentPlaceHolder id="PlaceHolderTopNavBar" runat="server">

    <hr>
    <h3>Typical tab navigation</h3>

            <!-- Tab bar -->
            <!-- required placeholder -->
            <asp:ContentPlaceHolder id="PlaceHolderHorizontalNav" runat="server">

                <!-- ASP.Menu based SharePoint menu - lots of customization possibilities here -->
                <SharePoint:AspMenu
                  ID="TopNavigationMenu"
                  Runat="server"
                  DataSourceID="topSiteMap"
                  EnableViewState="false"
                  AccessKey="<%$Resources:wss,navigation_accesskey%>"
                  Orientation="Horizontal"
                  StaticDisplayLevels="2"
                  MaximumDynamicDisplayLevels="1"
                  DynamicHorizontalOffset="0"
                  StaticPopoutImageUrl="/_layouts/images/menudark.gif"
                  StaticPopoutImageTextFormatString=""
                  DynamicHoverStyle-BackColor="#CBE3F0"
                  SkipLinkText=""
                  StaticSubMenuIndent="0"
                  CssClass="ms-topNavContainer">
                    <StaticMenuStyle/>
                    <StaticMenuItemStyle CssClass="ms-topnav" ItemSpacing="0px"/>
                    <StaticSelectedStyle CssClass="ms-topnavselected" />
                    <StaticHoverStyle CssClass="ms-topNavHover" />
                    <DynamicMenuStyle  BackColor="#F2F3F4" BorderColor="#A7B4CE" BorderWidth="1px"/>
                    <DynamicMenuItemStyle CssClass="ms-topNavFlyOuts"/>
                    <DynamicHoverStyle CssClass="ms-topNavFlyOutsHover"/>
                    <DynamicSelectedStyle CssClass="ms-topNavFlyOutsSelected"/>
                </SharePoint:AspMenu>
                <SharePoint:DelegateControl runat="server" ControlId="TopNavigationDataSource">
                    <Template_Controls>
                        <asp:SiteMapDataSource
                          ShowStartingNode="False"
                          SiteMapProvider="SPNavigationProvider"
                          id="topSiteMap"
                          runat="server"
                          StartingNodeUrl="sid:1002"/>
                    </Template_Controls>
                </SharePoint:DelegateControl>
            </asp:ContentPlaceHolder>
    <hr>

    <h3>Site actions menu</h3>

            <!-- optional - Site Actions Menu -->
            <SharePoint:SiteActions runat="server" AccessKey="<%$Resources:wss,tb_SiteActions_AK%>" id="SiteActionsMenuMain"
                PrefixHtml="&lt;div&gt;&lt;div&gt;"
                SuffixHtml="&lt;/div&gt;&lt;/div&gt;"
                MenuNotVisibleHtml="&amp;nbsp;">
                <CustomTemplate>
                <SharePoint:FeatureMenuTemplate runat="server"
                    FeatureScope="Site"
                    Location="Microsoft.SharePoint.StandardMenu"
                    GroupId="SiteActions"
                    UseShortId="true"
                    >
                    <SharePoint:MenuItemTemplate runat="server" id="MenuItem_Create"
                        Text="<%$Resources:wss,viewlsts_pagetitle_create%>"
                        Description="<%$Resources:wss,siteactions_createdescription%>"
                        ImageUrl="/_layouts/images/Actionscreate.gif"
                        MenuGroupId="100"
                        Sequence="100"
                        UseShortId="true"
                        ClientOnClickNavigateUrl="~site/_layouts/create.aspx"
                        PermissionsString="ManageLists, ManageSubwebs"
                        PermissionMode="Any" />
                    <SharePoint:MenuItemTemplate runat="server" id="MenuItem_EditPage"
                        Text="<%$Resources:wss,siteactions_editpage%>"
                        Description="<%$Resources:wss,siteactions_editpagedescription%>"
                        ImageUrl="/_layouts/images/ActionsEditPage.gif"
                        MenuGroupId="100"
                        Sequence="200"
                        ClientOnClickNavigateUrl="javascript:MSOLayout_ChangeLayoutMode(false);"
                        />
                    <SharePoint:MenuItemTemplate runat="server" id="MenuItem_Settings"
                        Text="<%$Resources:wss,settings_pagetitle%>"
                        Description="<%$Resources:wss,siteactions_sitesettingsdescription%>"
                        ImageUrl="/_layouts/images/ActionsSettings.gif"
                        MenuGroupId="100"
                        Sequence="300"
                        UseShortId="true"
                        ClientOnClickNavigateUrl="~site/_layouts/settings.aspx"
                        PermissionsString="EnumeratePermissions,ManageWeb,ManageSubwebs,AddAndCustomizePages,ApplyThemeAndBorder,ManageAlerts,ManageLists,ViewUsageData"
                        PermissionMode="Any" />
                </SharePoint:FeatureMenuTemplate>
                </CustomTemplate>
            </SharePoint:SiteActions>

            </asp:ContentPlaceHolder>

    <hr>
    <h3>Edit Consoles - Edit page, etc...</h3>

        <!-- Edit Page -->
        <asp:ContentPlaceHolder ID="WSSDesignConsole" runat="server">
            <wssuc:DesignModeConsole id="IdDesignModeConsole" runat="server"/>
        </asp:ContentPlaceHolder>
        <!-- Publishing site console -->
        <asp:ContentPlaceHolder ID="SPNavigation" runat="server">
            <SharePoint:DelegateControl runat="server" ControlId="PublishingConsole"
               PrefixHtml="&lt;tr&gt;&lt;td colspan=&quot;4&quot; id=&quot;mpdmconsole&quot; class=&quot;ms-consolemptablerow&quot;&gt;"
               SuffixHtml="&lt;/td&gt;&lt;/tr&gt;">
            </SharePoint:DelegateControl>
        </asp:ContentPlaceHolder>

    <hr>
    <h3>Typical Page Header</h3>

        <!-- Page Image -->
        <asp:ContentPlaceHolder id="PlaceHolderPageImage" runat="server"/>

        <!-- Breadcrumb trail for sub pages -->
        <asp:ContentPlaceHolder id="PlaceHolderTitleBreadcrumb" runat="server">
            <asp:SiteMapPath SiteMapProvider="SPContentMapProvider" id="ContentMap" SkipLinkText="" NodeStyle-CssClass="ms-sitemapdirectional" runat="server"/> &nbsp;
        </asp:ContentPlaceHolder>
        <!-- Page Title -->
        <asp:ContentPlaceHolder id="PlaceHolderPageTitleInTitleArea" runat="server" />
        <!-- Mini Console  -->
        <asp:ContentPlaceHolder id="PlaceHolderMiniConsole" runat="server"/>

    <hr>
    <h3>Typical Left Navigation</h3>

        <!-- Left navigation data source -->
        <asp:ContentPlaceHolder id="PlaceHolderLeftNavBarDataSource" runat="server" />
        <!-- Calendar date picker area - used by calendar views -->
        <asp:ContentPlaceHolder id="PlaceHolderCalendarNavigator" runat="server" />
        <!-- Quick Launch area including View All Site Content and Recycle bin -->
        <asp:ContentPlaceHolder id="PlaceHolderLeftNavBar" runat="server">

            <!-- View All Site Content -->
            <Sharepoint:SPSecurityTrimmedControl runat="server" PermissionsString="ViewFormPages">
                <SharePoint:SPLinkButton id="idNavLinkViewAll" runat="server" NavigateUrl="~site/_layouts/viewlsts.aspx" Text="<%$Resources:wss,quiklnch_allcontent%>" AccessKey="<%$Resources:wss,quiklnch_allcontent_AK%>"/>
            </SharePoint:SPSecurityTrimmedControl>
            <!-- Quick Launch menu -->
            <Sharepoint:SPNavigationManager
                id="QuickLaunchNavigationManager"
                runat="server"
                QuickLaunchControlId="QuickLaunchMenu"
                ContainedControl="QuickLaunch"
                EnableViewState="false">
                <SharePoint:DelegateControl runat="server" ControlId="QuickLaunchDataSource">
                    <Template_Controls>
                    <asp:SiteMapDataSource SiteMapProvider="SPNavigationProvider" ShowStartingNode="False" id="QuickLaunchSiteMap" StartingNodeUrl="sid:1025" runat="server" />
                 </Template_Controls>
                </SharePoint:DelegateControl>
                <SharePoint:AspMenu id="QuickLaunchMenu" DataSourceId="QuickLaunchSiteMap" runat="server" Orientation="Vertical" StaticDisplayLevels="2" ItemWrap="true" MaximumDynamicDisplayLevels="0" StaticSubMenuIndent="0" SkipLinkText="">
                    <LevelMenuItemStyles>
                        <asp:menuitemstyle CssClass="ms-navheader" />
                        <asp:menuitemstyle CssClass="ms-navitem" />
                    </LevelMenuItemStyles>
                    <LevelSubMenuStyles>
                        <asp:submenustyle CssClass="ms-navSubMenu1" />
                        <asp:submenustyle CssClass="ms-navSubMenu2" />
                    </LevelSubMenuStyles>
                    <LevelSelectedStyles>
                        <asp:menuitemstyle CssClass="ms-selectednavheader" />
                        <asp:menuitemstyle CssClass="ms-selectednav" />
                    </LevelSelectedStyles>
                </SharePoint:AspMenu>
            </Sharepoint:SPNavigationManager>
            <!--- Tree View - display controled in Site Settings, Tree view --->   
            <Sharepoint:SPNavigationManager
                id="TreeViewNavigationManager"
                runat="server"
                ContainedControl="TreeView">
                <SharePoint:SPLinkButton runat="server" NavigateUrl="~site/_layouts/viewlsts.aspx" id="idNavLinkSiteHierarchy" Text="<%$Resources:wss,treeview_header%>" AccessKey="<%$Resources:wss,quiklnch_allcontent_AK%>"/>
                <SharePoint:SPHierarchyDataSourceControl
                 runat="server"
                 id="TreeViewDataSource"
                 RootContextObject="Web"
                 IncludeDiscussionFolders="true"
                />
                <SharePoint:SPRememberScroll runat="server" id="TreeViewRememberScroll" onscroll="javascript:_spRecordScrollPositions(this);" Style="overflow: auto;height: 400px;width: 150px; ">
                <Sharepoint:SPTreeView
                    id="WebTreeView"
                    runat="server"
                    ShowLines="false"
                    DataSourceId="TreeViewDataSource"
                    ExpandDepth="0"
                    SelectedNodeStyle-CssClass="ms-tvselected"
                    NodeStyle-CssClass="ms-navitem"
                    NodeStyle-HorizontalPadding="2"
                    SkipLinkText=""
                    NodeIndent="12"
                    ExpandImageUrl="/_layouts/images/tvplus.gif"
                    CollapseImageUrl="/_layouts/images/tvminus.gif"
                    NoExpandImageUrl="/_layouts/images/tvblank.gif"
                >
                </Sharepoint:SPTreeView>
                </Sharepoint:SPRememberScroll>
            </Sharepoint:SPNavigationManager>
            <!-- Recycle Bin -->
            <SharePoint:SPLinkButton runat="server" NavigateUrl="~site/_layouts/recyclebin.aspx" id="idNavLinkRecycleBin" ImageUrl="/_layouts/images/recycbin.gif" Text="<%$Resources:wss,StsDefault_RecycleBin%>" PermissionsString="DeleteListItems"/>

        </asp:ContentPlaceHolder>

    <hr>
    <h3>Left Actions Area (used by wikis)</h3>

    <!-- Left Actions area placeholder - used by Wikis-->
    <asp:ContentPlaceHolder id="PlaceHolderLeftActions" runat="server"/>

    <hr>
    <h3>Page Content</h3>

        <!-- This div wraps the content area and is used by SharePoint to
        display the web part editor panel to the right of the web part zones -->

        <div id="MSO_ContentDiv" runat="server">
            <A name="mainContent"></A>
            <!-- Page Description -->
            <asp:ContentPlaceHolder id="PlaceHolderPageDescription" runat="server"/>
            <!-- Main content area -->
            <asp:ContentPlaceHolder id="PlaceHolderMain" runat="server">
            </asp:ContentPlaceHolder>
        </div>

    <hr>
    <h3>Form Digest Security Control (not visible)</h3>
    <!-- Form Digest Security Control -->
    <asp:ContentPlaceHolder id="PlaceHolderFormDigest" runat="server">
        <SharePoint:FormDigest runat=server/>
    </asp:ContentPlaceHolder>

    <input type="text" name="__spDummyText1" style="display:none;" size=1/>
    <input type="text" name="__spDummyText2" style="display:none;" size=1/>
    </form>

    <hr>
    <h3>Other required placeholders not generally needed by a custom master page</h3>

    <!-- Footer -->
    <asp:ContentPlaceHolder id="PlaceHolderUtilityContent" runat="server"/>
    <!-- Used to add body styles to the page header -->
    <asp:ContentPlaceHolder id="PlaceHolderBodyAreaClass" runat="server"/>
    <!-- Used to add styles to the page header -->
    <asp:ContentPlaceHolder id="PlaceHolderTitleAreaClass" runat="server"/>

        <asp:Panel visible="false" runat="server">
        <!-- PLACE UNUSED CONTENT PLACEHOLDERS HERE -->
        <!--- --- Placeholders used in default.master that you will likely not use --- --->
        <!-- Area between page image and page title -->
        <asp:ContentPlaceHolder id="PlaceHolderTitleLeftBorder" runat="server"/>
        <!-- Area between page name and right page border -->
        <asp:ContentPlaceHolder id="PlaceHolderTitleRightMargin" runat="server"/>
        <!-- Area between top nav bar and page content -->
        <asp:ContentPlaceHolder id="PlaceHolderTitleAreaSeparator" runat="server"/>
        <!-- Area above left nav bar -->
        <asp:ContentPlaceHolder id="PlaceHolderLeftNavBarTop" runat="server"/>
        <!-- Sets a width of the left nav bar -->
        <asp:ContentPlaceHolder id="PlaceHolderNavSpacer" runat="server"><IMG SRC="/_layouts/images/blank.gif" width=138 height=1 alt=""></asp:ContentPlaceholder>
        <!-- Area between left nav bar and page content -->
        <asp:ContentPlaceHolder id="PlaceHolderLeftNavBarBorder" runat="server"></asp:ContentPlaceHolder>
        <!-- Area between left nav and content -->
        <asp:ContentPlaceHolder id="PlaceHolderBodyLeftBorder" runat="server"/>
        <!-- Area between content and right page border -->
        <asp:ContentPlaceHolder id="PlaceHolderBodyRightMargin" runat="server"/>
        </asp:Panel>

    </BODY>
    </HTML>

    SharePoint Classes

    Here are some of the SharePoint related classes I teach at MAX Technical Training in the Cincinnati / Dayton Ohio area and nationwide. These classes are available both for local classroom and remote “Live Virtual Classroom” attendance.

     

    Can’t find a SharePoint class where and when you need it? MAX has partners nationwide offering remote “Live Virtual Classrooms”.

     

    MS-50196 Microsoft Office SharePoint Server 2007 Power User (MOSS)

    MS-5060 Implementing Windows SharePoint Services 3.0

    MS-5061 Implementing Microsoft Office SharePoint Server 2007

    MX-1019 SharePoint Designer 2007 - Customizing and Branding SharePoint

    MX-1022 HTML and CSS using SharePoint Designer

    MX-3530 Customizing SharePoint 2007 Applications

    MX-SPA401 Professional SharePoint Server 2007 Administration

    MX-WSS401 In-depth Development with Windows SharePoint Services 3.0

     

    MX-ONLSP Introduction to SharePoint 2007 Online

     

    MX-1023 InfoPath 2007

    2/03/2009

    PowerShell: Accessing SQL Data

    Using the .Net Framework and ADO.NET

    PS C:\> [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.SqlClient")

    PS C:\>

    PS C:\> $cn = New-Object System.Data.SqlClient.Sqlconnection

    PS C:\> $cn.ConnectionString = "server=10.10.0.50;database=adventureworks;integrated security=sspi"

    PS C:\> $cn.open()

    PS C:\>

    PS C:\> $cmd = new-object system.data.sqlclient.sqlcommand

    PS C:\> $cmd.CommandText = "select top 10 * from person.contacttype"

    PS C:\> $cmd.Connection = $cn

    PS C:\>

    PS C:\> $da = New-Object system.data.sqlclient.sqldataadapter

    PS C:\> $da.SelectCommand = $cmd

    PS C:\> $dt = New-Object system.data.datatable

    PS C:\> $da.Fill($dt)

    PS C:\> $cn.close()

    PS C:\>

    PS C:\> $dt ft * -AutoSize

    ContactTypeID Name ModifiedDate
    ------------- ---- ------------
    1 Accounting Manager 6/1/1998 12:00:00 AM
    2 Assistant Sales Agent 6/1/1998 12:00:00 AM
    3 Assistant Sales Representative 6/1/1998 12:00:00 AM
    4 Coordinator Foreign Markets 6/1/1998 12:00:00 AM
    5 Export Administrator 6/1/1998 12:00:00 AM
    6 International Marketing Manager 6/1/1998 12:00:00 AM
    7 Marketing Assistant 6/1/1998 12:00:00 AM
    8 Marketing Manager 6/1/1998 12:00:00 AM
    9 Marketing Representative 6/1/1998 12:00:00 AM
    10 Order Administrator 6/1/1998 12:00:00 AM

    Using a "sample" SQL Provider

    http://blogs.msdn.com/powershell/archive/2007/06/21/demo-sql-provider-code.aspx

    PS C:\> . $env:Windir\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe .\sqlprovider\SQLProvider.dll

    PS C:\> Add-PSSnapin sqlprototypeprovider

    PS C:\> cd sql:

    PS SQL:\> cd miami

    PS SQL:\miami>

    PS SQL:\miami> dir master tempdb model msdb ReportServer ReportServerTempDB AdventureWorksDW AdventureWorks

    PS SQL:\miami> cd adventureworks

    PS SQL:\miami\adventureworks> dir name ---- Address AddressType AWBuildVersion BillOfMaterials Contact ContactCreditCard

    PS SQL:\miami\adventureworks> cd person.contacttype

    PS SQL:\miami\adventureworks\person.contacttype> dir

    PS SQL:\miami\adventureworks> cd person.contacttype

    PS SQL:\miami\adventureworks\person.contacttype> dir ft –AutoSize

    ContactTypeID Name ModifiedDate ------------- ---- ------------

    1 Accounting Manager 6/1/1998 12:00:00 AM
    2 Assistant Sales Agent 6/1/1998 12:00:00 AM
    3 Assistant Sales Representative 6/1/1998 12:00:00 AM
    4 Coordinator Foreign Markets 6/1/1998 12:00:00 AM
    5 Export Administrator 6/1/1998 12:00:00 AM
    6 International Marketing Manager 6/1/1998 12:00:00 AM
    7 Marketing Assistant 6/1/1998 12:00:00 AM
    8 Marketing Manager 6/1/1998 12:00:00 AM
    9 Marketing Representative 6/1/1998 12:00:00 AM
    10 Order Administrator 6/1/1998 12:00:00 AM
    11 Owner 6/1/1998 12:00:00 AM
    12 Owner/Marketing Assistant 6/1/1998 12:00:00 AM
    13 Product Manager 6/1/1998 12:00:00 AM
    14 Purchasing Agent 6/1/1998 12:00:00 AM
    15 Purchasing Manager 6/1/1998 12:00:00 AM
    16 Regional Account Representative 6/1/1998 12:00:00 AM
    17 Sales Agent 6/1/1998 12:00:00 AM
    18 Sales Associate 6/1/1998 12:00:00 AM
    19 Sales Manager 6/1/1998 12:00:00 AM
    20 Sales Representative 6/1/1998 12:00:00 AM

    PowerShell

    PowerShell Online Resources:

    1/27/2009

    SharePoint: DOCTYPE Notes

    SharePoint Designer Notes:

    New pages get a DOCTYPE from:

      Tools -> Page Editor Options -> Authoring -> Document Type Declaration

    Existing pages with no (or invalid) DOCTYPE get:

      Tools -> Page Editor Options -> Authoring -> Secondary Schema

    The schema used for IntelliSense validation is set here:

      Tools -> Page Editor Options -> Authoring -> CSS Schema

     

    General SharePoint DOCTYPE Notes:

    SharePoint WSS out-of-the-box templates do not specify a DOCTYPE while publishing templates use HTML 4.01 Transitional (and be aware these often have inconsistent and sometimes mal-formed HTML - try validating a SharePoint page here sometime: http://validator.w3.org)

    It may be best to create SharePoint pages with no DOCTYPE specified. Each DOCTYPE seems to cause a problem somewhere. See here and read the comments: http://www.heathersolomon.com/blog/archive/2007/02/21/6213.aspx

     

    Possible DOCTYPEs:

    See: http://www.w3schools.com/tags/tag_DOCTYPE.asp

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

     

    Related:

    IF you are using a DOCTYPE, then force IE8 to render pages in IE7 format:

    <meta http-equiv="X-UA-Compatible" content="IE=7" />

    Resources:

    http://www.heathersolomon.com/blog/archive/2008/01/25/DOCTYPES-and-SharePoint.aspx

    http://www.w3schools.com/tags/tag_DOCTYPE.asp

    plus any web search on DOCTYPE

    1/18/2009

    ASP.NET State Management Comparison



    The following is a chart that I often use in ASP.Net classes to compare State Management options.
    Where?What?Who can seeLife spanIssuesNew inNotes
    Cookies
    Request.Cookies
    Response.Cookies
    User's browser or diskstringscurrent usercurrent browser session or set expire datelimited data size (typically 4096 bytes), cookie limit (typically 20 per site)user can disableancient history!  
    Hidden HTML fieldsbrowserstringscurrent userone page postback (one round trip)limited to text and visible as Page Source textancient history! Easy to hack!
    Applicationweb server RAM (1)objectsall sessionsuntil server is restartedlimited by RAMClassic ASP 
    Sessionweb server RAM (1)objectscurrent userend of user's session (Session.Abandon or timeout [default 20 minutes])limited by RAMClassic ASP 
    ViewStatehidden INPUT in pageobjectscurrent userone page postback (one round trip)bandwidth and slower page load <i>and</i> post timesASP.Net 1.0Can be disabled by the developer (per page, web.config or code)
    ControlStatein ViewStateobjectscurrent userone page postback (one round trip)Not as simple to use as ViewStateASP.Net 2.0Cannot be disabled by the developer using the control
    Cache (2)web server RAMobjectsall sessionsUntil:
    - Expires
    - a dependency changes
    - RAM is needed
    You must always check to see if the object still exists as cached items are both automatically deleted and are deleted when RAM runs low. ASP.Net 1.0Can be used as an Application object that can expire

     

    (1) State can be stored in local server RAM (InProc), another server's RAM (StateServer), SQL Server (SQLServer) or a custom destination. For any option other than InProc all objects must be serializable.

    (2) Cache is not usually mentioned in lists of state options, but is nearly identical to Application with the addition of expiration.



    Note to spammers!

    Spammers, don't waste your time... all posts are moderated. If your comment includes unrelated links, is advertising, or just pure spam, it will never be seen.