I am working with Sharepoint Services and am trying to add the
fileversion Metadata to the Versions.aspx page using the example from
the SDK. I have not done much with hashtables but it all looks
straightforward in the SDK.
The code segment added is below. The commented out lines (<!-- )are for
testing and work correctly. i.e. I can create a NEW hashtable, add
items to it, and display them on the Versions.aspx page. When I try to
create a new Hashtable from the Properties of the SPFileVersion Class I
get an error.
<% Hashtable hash = ver.Properties; %> This line creates the error.
Clearly I am referencing 'ver.Properties' incorrectly but i can't
figure it out.
<TD class="ms-vb2" valign="top">
<% Hashtable hash = ver.Properties; %>
<!-- Hashtable hash = new Hashtable();-->
<!-- hash.Add("First", "Hello");-->
<!-- hash.Add("Second", "World");-->
<!-- hash.Add("Third", "!");-->
<% ICollection keys = hash.Keys; %>
<% foreach (object key in keys) %>
<% { %>
<% Response.Write(SPEncode.HtmlEn*code(key.ToString() ) + " :: " +
SPEncode.HtmlEncode(hash[key.T*oString()].ToString()) + "<BR>"); %>
<% } %>
</TD>
The SDK reference for this is the Properties (gets metadata for the
fileversion):
http://msdn.microsoft.com/library/de...SV01013560.asp
Any clues?
Complete listing of Versions.aspx below:
<!-- _lcid="1033" _version="11.0.5510" _dal="1" -->
<!-- _LocalBinding -->
<%@ Import namespace ="Microsoft.SharePoint.Utiliti*es" %>
<%@ Page Language="C#"
Inherits="Microsoft.SharePoint*.ApplicationPages.L istPage"
ValidateRequest="False" %> <%@ Import
Namespace="Microsoft.SharePoin*t.ApplicationPages" %> <%@ Register
Tagprefix="SharePoint" Namespace="Microsoft.SharePoin*t.WebControls"
Assembly="Microsoft.SharePoint*, Version=11.0.0.0, Culture=neutral,
PublicKeyToken=71e9bce111e9429*c" %> <%@ Register
Tagprefix="Utilities"
Namespace="Microsoft.SharePoin*t.Utilities"
Assembly="Microsoft.SharePoint*, Version=11.0.0.0, Culture=neutral,
PublicKeyToken=71e9bce111e9429*c" %> <%@ Import
Namespace="Microsoft.SharePoin*t" %> <% SPSite spServer =
SPControl.GetContextSite(Conte*xt); SPWeb spWeb =
SPControl.GetContextWeb(Contex*t); %>
<HTML dir="ltr">
<HEAD>
<META Name="GENERATOR" Content="Microsoft SharePoint">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<META HTTP-EQUIV="Expires" content="0">
<Title ID=onetidTitle>Versions</Title*>
<script
src="file://Mnm-server/Program*%20Files/Common%20Files/Micros*oft%20Shared/web%20server%20ex*tensions/60/TEMPLATE/LAYOUTS/1*033/owsbrows.js"></script>
<SharePoint:CssLink DefaultUrl="styles/ows.css" runat="server"/>
<SharePoint:Theme runat="server"/>
<script><!--
if (browseris.mac && !browseris.ie5up)
{
var ms_maccssfpfixup = "styles/owsmac.css";
document.write("<link rel='stylesheet' Type='text/css' href='" +
ms_maccssfpfixup + "'>");
}
//--></script>
<script
src="file://Mnm-server/Program*%20Files/Common%20Files/Micros*oft%20Shared/web%20server%20ex*tensions/60/TEMPLATE/LAYOUTS/1*033/ows.js"></script>
<SharePoint:CustomJSUrl runat="server" />
<link type="text/xml" rel='alternate'
href="file://Mnm-server/Progra*m%20Files/Common%20Files/Micro*soft%20Shared/web%20server%20e*xtensions/60/TEMPLATE/LAYOUTS/*1033/_vti_bin/spdisco.aspx"/>
</HEAD>
<SCRIPT language="JavaScript">
ctx = new ContextInfo();
ctx.isVersions = 1;
ctx.HttpRoot = <% SPEncode.WriteScriptEncodeWith*Quote(Response,
m_web.Url, '"'); %>;
ctx.HttpPath = <% SPEncode.WriteScriptEncodeWith*Quote(Response,
SortUrl(), '"'); %>;
ctx.imagesPath = "../images/";
ctx.verEnabled = <% SPEncode.WriteNoEncode(Respons*e,
VersioningEnabled
? 1 : 0); %>;
ctxVer = ctx;
var MSOWebPartPageFormName = <%
SPEncode.WriteScriptEncodeWith*Quote(Response, MainForm.Name, '"');
%>;
</SCRIPT>
<BODY marginwidth="0" marginheight="0" scroll="yes">
<!-- WOW Our code-behind needs a chance to insert the editmenu
setup
script -->
<FORM runat="server" id="MainForm">
<TABLE class="ms-main" cellpadding="0" cellspacing="0"
border="0"
width="100%" height="100%">
<!-- Banner -->
<%
string alternateHeader =
SPControl.GetContextWeb(Contex*t).AlternateHeader;
if (alternateHeader == null || alternateHeader == "")
{
%>
<TR>
<TD COLSPAN=3 WIDTH=100%>
<!--Top bar-->
<table class="ms-bannerframe" border="0" cellspacing="0"
cellpadding="0" width="100%">
<tr>
<td nowrap valign="middle"><img ID=onetidHeadbnnr0 alt="Logo"
src="/_layouts/images/logo.gif*"></td>
<td class=ms-banner width=99% nowrap ID="HBN100" valign="middle">
<!--webbot Bot="Navigation" startspan-->
<SharePoint:Navigation LinkBarId="1002" runat="server"/>
</td>
<td class=ms-banner> </td>
<td nowrap class=ms-banner style="padding-right: 7px">
<SharePoint:PortalConnection runat="server" />
</td>
</tr>
</table>
</TD>
</TR>
<%
}
else
{
Server.Execute(alternateHeader*);
}
%>
<!-- Item Title -->
<tr> <td colspan=3 class="ms-titleareaframe">
<div
class="ms-titleareaframe"> <table width=100% border=0
class="ms-titleareaframe" cellpadding=0 cellspacing=0> <tr> <td
style="padding-bottom: 0px"> <table style="padding-top:
0px;padding-left: 2px" cellpadding=0 cellspacing=0 border=0> <tr> <td
align=center nowrap style="padding-top: 4px" width="108" height="46">
<img ID=onetidtpweb1 src="/_layouts/images/blank.gi*f" alt="Icon"
height="49" width="49"> </td> <td><IMG
SRC="/_layouts/images/blank.gi*f"
width=22 height=1 alt=""></td> <td nowrap width="100%"
style="padding-top: 0px"> <table cellpadding=0 cellspacing=0> <tr> <td
nowrap class="ms-titlearea"> <SharePoint:ProjectProperty
Property="Title" runat="server"/> </td> </tr> <tr> <td
ID=onetidPageTitle class="ms-pagetitle">Versions saved for <A
id="onetidVersionsEditTitle" href=<%
SPEncode.WriteUrlEncodeAsUrlWi*thQuote(Response,
m_file.ServerRelativeUrl, '"'); %> onclick="DispDocItem(this)"><%
SPEncode.WriteHtmlEncode(Respo*nse, m_file.Name); %></A><!-- --></td>
</tr> </table> </td> </tr> </table> <table cellpadding=0 cellspacing=0
border=0 width=100%> <tr> <td class="ms-titlearealine" height=1
colspan=5><IMG SRC="/_layouts/images/blank.gi*f" width=1 height=1
alt=""></td> </tr> </table> </td> </tr> </table> </div> </td> </tr>
<TR valign="top">
<!-- Navigation -->
<TD height="100%" class="ms-nav">
<TABLE height="100%"
style="padding-top: 8px" class="ms-navframe"
cellpadding="0" cellspacing="0" border="0" width="126px">
<TR valign="top">
<TD
width="4px"><IMG SRC="/_layouts/images/blank.gi*f" width=1
height=1 alt=""></TD>
<TD>
<TABLE
width="100%" cellpadding="0" cellspacing="2" border="0">
<% if (List != null) { %>
<TR><TD width="100%" ID="L_RelatedTasks">Actions</T*D></TR>
<TR><TD class="ms-navline"><IMG
SRC="/_layouts/images/blank.gi*f" width=1 height=1 alt=""></TD></TR>
<TR>
<TD style="padding-left: 2px;padding-bottom: 2px"
width="100%">
<TABLE border="0" cellpadding="0"
cellspacing="0"
width="100%">
<TR>
<TD width"=100%"
class="ms-unselectednav" colspan="2">
<TABLE cellpadding="0"
cellspacing="0" border="0">
<TR>
<TD
valign="top">
<IMG src="../images/rect.gif">
</TD>
<TD>
<A accesskey="M" id="diidVersionsModifySettings*"
href="lstSetng.aspx?list=<% SPEncode.WriteUrlEncode(Respon*se,
m_listId); %>">
Modify versioning settings
</A>
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
</TD>
</TR>
<% } %>
</TABLE>
</TD>
<TD
class="ms-verticaldots"> </TD>
</TR>
</TABLE>
</TD>
<!-- Page overview -->
<TD style="padding-top:
3px;padding-left: 10px;padding-right: 10px"
class="ms-bodyareaframe" width="100%">
<!-- Intro -->
<TABLE width="100%" border="0"
cellpadding="0" cellspacing="2">
<TR>
<TD
class="ms-descriptiontext" style="padding-bottom: 10px">
<% if
(VersioningEnabled)
{
if (List != null && List.BaseTemplate ==
SPListTemplateType.PictureLibr*ary)
{
%>
Versions are currently enabled for this picture library.
<%
} else {
%>
Versions are currently enabled for this document library.
<%
}
} else {
if (List != null && List.BaseTemplate ==
SPListTemplateType.PictureLibr*ary)
{
%>
Versions are currently disabled for this picture library.
<%
} else {
%>
Versions are currently disabled for this document library.
<%
}
}
%>
</TD>
</TR>
</TABLE>
<!-- Toolbar -->
<TABLE class="ms-toolbar"
style="margin-left: 3px;" cellpadding=2
cellspacing=0 border=0> <TR>
<td class="ms-toolbar"> <table
cellpadding=1 cellspacing=0
border=0> <tr> <td class="ms-toolbar" nowrap> <a tabindex=2
ID="diidVersionsDeleteAll" class="ms-toolbar" ACCESSKEY=X
href="javascript:DeleteAllVers*ions(<%
SPEncode.WriteHtmlEncode(Respo*nse, m_versions.Count.ToString());%*>,
ctxVer)" title="Delete Previous Versions"><img
src="../images/delitem.gif" ID="tbbutton1X" alt="Delete Previous
Versions" border=0 width=16 height=16></a></td> <td nowrap> <a
tabindex=2 class="ms-toolbar" ACCESSKEY=X ID="diidVersionsDeleteAll"
href="javascript:DeleteAllVers*ions(<%
SPEncode.WriteHtmlEncode(Respo*nse, m_versions.Count.ToString());%*>,
ctxVer)">Delete Previous Versions</a></td> </tr></table></td>
<% if (m_urlSource != null &&
m_urlSource != "" &&
List != null)
{ %>
<TD
class=ms-separator>|</TD>
<%
switch(List.BaseTemplate)
{
case
SPListTemplateType.PictureLibr*ary:
{ %>
<td
class="ms-toolbar"> <table cellpadding=1 cellspacing=0
border=0> <tr> <td nowrap><a tabindex=2 class="ms-toolbar" ACCESSKEY=G
ID="diidVersionsGoBack" href="javascript:GoBack()">Go Back to Picture
Library</a></td> </tr></table></td>
<% break;
}
case
SPListTemplateType.XMLForm:
{ %>
<td
class="ms-toolbar"> <table cellpadding=1 cellspacing=0
border=0> <tr> <td nowrap><a tabindex=2 class="ms-toolbar" ACCESSKEY=G
ID="diidVersionsGoBack" href="javascript:GoBack()">Go Back to Form
Library</a></td> </tr></table></td>
<% break;
}
case
SPListTemplateType.WebTemplate*Catalog:
case
SPListTemplateType.ListTemplat*eCatalog:
{ %>
<td
class="ms-toolbar"> <table cellpadding=1 cellspacing=0
border=0> <tr> <td nowrap><a tabindex=2 class="ms-toolbar" ACCESSKEY=G
ID="diidVersionsGoBack" href="javascript:GoBack()">Go Back to
Gallery</a></td> </tr></table></td>
<% break;
}
default:
{ %>
<td
class="ms-toolbar"> <table cellpadding=1 cellspacing=0
border=0> <tr> <td nowrap><a tabindex=2 class="ms-toolbar" ACCESSKEY=G
ID="diidVersionsGoBack" href="javascript:GoBack()">Go Back to Document
Library</a></td> </tr></table></td>
<% break;
}
}
} %>
<TD width=99%
class="ms-toolbar" align=right nowrap
id=align01><IMG SRC="/_layouts/images/blank.gi*f" width=1 height=1
alt=""></td> </tr> </table>
<TABLE width="100%" border="0"
cellpadding="0" cellspacing="2">
<TR>
<TD
height="3"><IMG SRC="/_layouts/images/blank.gi*f" width=1
height=1 alt=""></TD>
</TR>
</TABLE>
<!-- Version list -->
<TABLE width="100%" border="0"
cellpadding="1" cellspacing="0"
rules="rows">
<!-- List header -->
<TR>
<TH
class="ms-vh2">
<A
id="diidVersionsSortNumber" title="Sort By No." href=<%
SPEncode.WriteUrlEncodeAsUrlWi*thQuote(Response, SortUrl("Number"),
'"'); %>>
No.
</A>
<% if
(m_sortCol == "Number") %>
<% { %>
<IMG SRC=<% SPEncode.WriteUrlEncodeAsUrlWi*thQuote(Response,
SortImage(), '"'); %> ALT=<%
SPEncode.WriteHtmlEncodeWithQu*ote(Response, SortAlt(), '"'); %>
BORDER=0>
<% } %>
</TH>
<TH
class="ms-vh2">
<A
id="diidVersionsSortModified" title="Sort By Modified"
href=<% SPEncode.WriteUrlEncodeAsUrlWi*thQuote(Response,
SortUrl("Modified"), '"'); %>>
Modified
</A>
<% if
(m_sortCol == "Modified") %>
<% { %>
<IMG SRC=<% SPEncode.WriteUrlEncodeAsUrlWi*thQuote(Response,
SortImage(), '"'); %> ALT=<%
SPEncode.WriteHtmlEncodeWithQu*ote(Response, SortAlt(), '"'); %>
BORDER=0>
<% } %>
</TH>
<TH
class="ms-vh2">
<A
id="diidVersionsSortModifiedBy*" title="Sort By Modified By"
href=<% SPEncode.WriteUrlEncodeAsUrlWi*thQuote(Response,
SortUrl("ModifiedBy"), '"'); %>>
Modified By
</A>
<% if
(m_sortCol == "ModifiedBy") %>
<% { %>
<IMG SRC=<% SPEncode.WriteUrlEncodeAsUrlWi*thQuote(Response,
SortImage(), '"'); %> ALT=<%
SPEncode.WriteHtmlEncodeWithQu*ote(Response, SortAlt(), '"'); %>
BORDER=0>
<% } %>
</TH>
<TH
class="ms-vh2">
<A
id="diidVersionsSortSize" title="Sort By Size" href=<%
SPEncode.WriteUrlEncodeAsUrlWi*thQuote(Response, SortUrl("Size"),
'"');
%>>
Size
</A>
<% if
(m_sortCol == "Size") %>
<% { %>
<IMG SRC=<% SPEncode.WriteUrlEncodeAsUrlWi*thQuote(Response,
SortImage(), '"'); %> ALT=<%
SPEncode.WriteHtmlEncodeWithQu*ote(Response, SortAlt(), '"'); %>
BORDER=0>
<% } %>
</TH>
<TH
class="ms-vh2">
<A
id="diidVersionsSortComments" title="Sort By Comments"
href=<% SPEncode.WriteUrlEncodeAsUrlWi*thQuote(Response,
SortUrl("Comments"), '"'); %>>
CommentsTEST
</A>
<% if
(m_sortCol == "Comments") %>
<% { %>
<IMG SRC=<% SPEncode.WriteUrlEncodeAsUrlWi*thQuote(Response,
SortImage(), '"'); %> ALT=<%
SPEncode.WriteHtmlEncodeWithQu*ote(Response, SortAlt(), '"'); %>
BORDER=0>
<% } %>
</TH>
</TR>
<TR>
<TD
colspan="4"><IMG SRC="/_layouts/images/blank.gi*f" width=1
height=1 alt=""></TD>
</TR>
<!-- List items -->
<% for (int c = 0; c <
m_versions.Count; ++c) %>
<% { %>
<%
ISPFileVersion ver = (ISPFileVersion)m_versions[c]; %>
<TR>
<TD
class="ms-vb2" valign="top">
<% SPEncode.WriteHtmlEncode(Respo*nse, ver.ID.ToString()); %>
</TD>
<TD
class="ms-vb-title" valign="top">
<TABLE class="ms-unselectedtitle" onmouseover=OnItem(this)
cellspacing="0" CTXName="ctxVer"
ItemId=<%SPEncode.WriteHtmlEnc*odeWithQuote(Respon se,
ver.ID.ToString(),
'"'); %> verId=<% SPEncode.WriteHtmlEncodeWithQu*ote(Response,
ver.ID.ToString(), '"'); %> verUrl=<%
SPEncode.WriteUrlEncodeAsUrlWi*thQuote(Response, m_web.Url + "/" +
ver.Url, '"'); %> isCur=<%
SPEncode.WriteHtmlEncodeWithQu*ote(Response,
ver.ID == m_file.UIVersion ? "1" : "0", '"'); %>>
<TBODY>
<TR>
<TD class="ms-vb" width="100%">
<A onfocus=OnLink(this) href=<%
SPEncode.WriteUrlEncodeAsUrlWi*thQuote(Response, m_web.Url + "/" +
ver.Url, '"'); %> onclick="DispDocItem(this)"><%
SPEncode.WriteHtmlEncode(Respo*nse, SPUtility.FormatDate(m_web,
ver.Created, SPDateFormat.DateTime)); %></A>
</TD>
<TD><img style="visibility:hidden"
src="../images/blank.gif" width="13" alt=""></TD>
</TR>
</TBODY>
</TABLE>
</TD>
<TD
class="ms-vb2" valign="top">
<% if (ver.CreatedBy != null) %>
<% { %>
<% SPEncode.WriteHtmlEncode(Respo*nse, ver.CreatedBy); %>
<% } %>
</TD>
<TD
class="ms-vb2" valign="top">
<% SPEncode.WriteHtmlEncode(Respo*nse,
SizeConversion(ver.Size)); %>
</TD>
<TD
class="ms-vb2" valign="top">
<% SPEncode.WriteHtmlEncodePreser*veSpaces(Response,
ver.CheckInComment); %>
</TD>
<TD class="ms-vb2"
valign="top">
<% Hashtable hash =
ver.Properties; %>
<!-- hash =
ver.Properties; -->
<% hash.Add("First",
"Hello");%>
<% hash.Add("Second",
"World");%>
<% hash.Add("Third",
"!");%>
<% ICollection keys =
hash.Keys; %>
<% foreach (object key
in keys) %>
<% { %>
<%
Response.Write(SPEncode.HtmlEn*code(key.ToString() ) + "
:: " + SPEncode.HtmlEncode(hash[key.T*oString()].ToString()) +
"<BR>");
%>
<% } %>
</TD>
</TR>
<% } %>
</TABLE>
</TD>
</TR>
</TABLE>
<SharePoint:FormDigest runat=server/>
</FORM>
</BODY>
</HTML>