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("Secon d", "World");-->
<!-- hash.Add("Third ", "!");-->
<% ICollection keys = hash.Keys; %>
<% foreach (object key in keys) %>
<% { %>
<% Response.Write( SPEncode.HtmlEn *code(key.ToStr ing()) + " :: " +
SPEncode.HtmlEn code(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.Sha rePoint.Utiliti *es" %>
<%@ Page Language="C#"
Inherits="Micro soft.SharePoint *.ApplicationPa ges.ListPage"
ValidateRequest ="False" %> <%@ Import
Namespace="Micr osoft.SharePoin *t.ApplicationP ages" %> <%@ Register
Tagprefix="Shar ePoint" Namespace="Micr osoft.SharePoin *t.WebControls"
Assembly="Micro soft.SharePoint *, Version=11.0.0. 0, Culture=neutral ,
PublicKeyToken= 71e9bce111e9429 *c" %> <%@ Register
Tagprefix="Util ities"
Namespace="Micr osoft.SharePoin *t.Utilities"
Assembly="Micro soft.SharePoint *, Version=11.0.0. 0, Culture=neutral ,
PublicKeyToken= 71e9bce111e9429 *c" %> <%@ Import
Namespace="Micr osoft.SharePoin *t" %> <% SPSite spServer =
SPControl.GetCo ntextSite(Conte *xt); SPWeb spWeb =
SPControl.GetCo ntextWeb(Contex *t); %>
<HTML dir="ltr">
<HEAD>
<META Name="GENERATOR " Content="Micros oft 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*%20File s/Common%20Files/Micros*oft%20Sh ared/web%20server%20 ex*tensions/60/TEMPLATE/LAYOUTS/1*033/owsbrows.js"></script>
<SharePoint:Css Link DefaultUrl="sty les/ows.css" runat="server"/>
<SharePoint:The me runat="server"/>
<script><!--
if (browseris.mac && !browseris.ie5u p)
{
var ms_maccssfpfixu p = "styles/owsmac.css";
document.write( "<link rel='stylesheet ' Type='text/css' href='" +
ms_maccssfpfixu p + "'>");
}
//--></script>
<script
src="file://Mnm-server/Program*%20File s/Common%20Files/Micros*oft%20Sh ared/web%20server%20 ex*tensions/60/TEMPLATE/LAYOUTS/1*033/ows.js"></script>
<SharePoint:Cus tomJSUrl runat="server" />
<link type="text/xml" rel='alternate'
href="file://Mnm-server/Progra*m%20File s/Common%20Files/Micro*soft%20Sh ared/web%20server%20 e*xtensions/60/TEMPLATE/LAYOUTS/*1033/_vti_bin/spdisco.aspx"/>
</HEAD>
<SCRIPT language="JavaS cript">
ctx = new ContextInfo();
ctx.isVersions = 1;
ctx.HttpRoot = <% SPEncode.WriteS criptEncodeWith *Quote(Response ,
m_web.Url, '"'); %>;
ctx.HttpPath = <% SPEncode.WriteS criptEncodeWith *Quote(Response ,
SortUrl(), '"'); %>;
ctx.imagesPath = "../images/";
ctx.verEnabled = <% SPEncode.WriteN oEncode(Respons *e,
VersioningEnabl ed
? 1 : 0); %>;
ctxVer = ctx;
var MSOWebPartPageF ormName = <%
SPEncode.WriteS criptEncodeWith *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.GetCo ntextWeb(Contex *t).AlternateHe ader;
if (alternateHeade r == 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=onetidHeadbn nr0 alt="Logo"
src="/_layouts/images/logo.gif*"></td>
<td class=ms-banner width=99% nowrap ID="HBN100" valign="middle" >
<!--webbot Bot="Navigation " startspan-->
<SharePoint:Nav igation LinkBarId="1002 " runat="server"/>
</td>
<td class=ms-banner> </td>
<td nowrap class=ms-banner style="padding-right: 7px">
<SharePoint:Por talConnection 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:Pro jectProperty
Property="Title " runat="server"/> </td> </tr> <tr> <td
ID=onetidPageTi tle class="ms-pagetitle">Vers ions saved for <A
id="onetidVersi onsEditTitle" href=<%
SPEncode.WriteU rlEncodeAsUrlWi *thQuote(Respon se,
m_file.ServerRe lativeUrl, '"'); %> onclick="DispDo cItem(this)"><%
SPEncode.WriteH tmlEncode(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"><IM G 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_RelatedTa sks">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="diidVersion sModifySettings *"
href="lstSetng. aspx?list=<% SPEncode.WriteU rlEncode(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
(VersioningEnab led)
{
if (List != null && List.BaseTempla te ==
SPListTemplateT ype.PictureLibr *ary)
{
%>
Versions are currently enabled for this picture library.
<%
} else {
%>
Versions are currently enabled for this document library.
<%
}
} else {
if (List != null && List.BaseTempla te ==
SPListTemplateT ype.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="diidVersion sDeleteAll" class="ms-toolbar" ACCESSKEY=X
href="javascrip t:DeleteAllVers *ions(<%
SPEncode.WriteH tmlEncode(Respo *nse, m_versions.Coun t.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="diidVersion sDeleteAll"
href="javascrip t:DeleteAllVers *ions(<%
SPEncode.WriteH tmlEncode(Respo *nse, m_versions.Coun t.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.Bas eTemplate)
{
case
SPListTemplateT ype.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="diidVersion sGoBack" href="javascrip t:GoBack()">Go Back to Picture
Library</a></td> </tr></table></td>
<% break;
}
case
SPListTemplateT ype.XMLForm:
{ %>
<td
class="ms-toolbar"> <table cellpadding=1 cellspacing=0
border=0> <tr> <td nowrap><a tabindex=2 class="ms-toolbar" ACCESSKEY=G
ID="diidVersion sGoBack" href="javascrip t:GoBack()">Go Back to Form
Library</a></td> </tr></table></td>
<% break;
}
case
SPListTemplateT ype.WebTemplate *Catalog:
case
SPListTemplateT ype.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="diidVersion sGoBack" href="javascrip t: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="diidVersion sGoBack" href="javascrip t: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="diidVersion sSortNumber" title="Sort By No." href=<%
SPEncode.WriteU rlEncodeAsUrlWi *thQuote(Respon se, SortUrl("Number "),
'"'); %>>
No.
</A>
<% if
(m_sortCol == "Number") %>
<% { %>
<IMG SRC=<% SPEncode.WriteU rlEncodeAsUrlWi *thQuote(Respon se,
SortImage(), '"'); %> ALT=<%
SPEncode.WriteH tmlEncodeWithQu *ote(Response, SortAlt(), '"'); %>
BORDER=0>
<% } %>
</TH>
<TH
class="ms-vh2">
<A
id="diidVersion sSortModified" title="Sort By Modified"
href=<% SPEncode.WriteU rlEncodeAsUrlWi *thQuote(Respon se,
SortUrl("Modifi ed"), '"'); %>>
Modified
</A>
<% if
(m_sortCol == "Modified") %>
<% { %>
<IMG SRC=<% SPEncode.WriteU rlEncodeAsUrlWi *thQuote(Respon se,
SortImage(), '"'); %> ALT=<%
SPEncode.WriteH tmlEncodeWithQu *ote(Response, SortAlt(), '"'); %>
BORDER=0>
<% } %>
</TH>
<TH
class="ms-vh2">
<A
id="diidVersion sSortModifiedBy *" title="Sort By Modified By"
href=<% SPEncode.WriteU rlEncodeAsUrlWi *thQuote(Respon se,
SortUrl("Modifi edBy"), '"'); %>>
Modified By
</A>
<% if
(m_sortCol == "ModifiedBy ") %>
<% { %>
<IMG SRC=<% SPEncode.WriteU rlEncodeAsUrlWi *thQuote(Respon se,
SortImage(), '"'); %> ALT=<%
SPEncode.WriteH tmlEncodeWithQu *ote(Response, SortAlt(), '"'); %>
BORDER=0>
<% } %>
</TH>
<TH
class="ms-vh2">
<A
id="diidVersion sSortSize" title="Sort By Size" href=<%
SPEncode.WriteU rlEncodeAsUrlWi *thQuote(Respon se, SortUrl("Size") ,
'"');
%>>
Size
</A>
<% if
(m_sortCol == "Size") %>
<% { %>
<IMG SRC=<% SPEncode.WriteU rlEncodeAsUrlWi *thQuote(Respon se,
SortImage(), '"'); %> ALT=<%
SPEncode.WriteH tmlEncodeWithQu *ote(Response, SortAlt(), '"'); %>
BORDER=0>
<% } %>
</TH>
<TH
class="ms-vh2">
<A
id="diidVersion sSortComments" title="Sort By Comments"
href=<% SPEncode.WriteU rlEncodeAsUrlWi *thQuote(Respon se,
SortUrl("Commen ts"), '"'); %>>
CommentsTEST
</A>
<% if
(m_sortCol == "Comments") %>
<% { %>
<IMG SRC=<% SPEncode.WriteU rlEncodeAsUrlWi *thQuote(Respon se,
SortImage(), '"'); %> ALT=<%
SPEncode.WriteH tmlEncodeWithQu *ote(Response, SortAlt(), '"'); %>
BORDER=0>
<% } %>
</TH>
</TR>
<TR>
<TD
colspan="4"><IM G SRC="/_layouts/images/blank.gi*f" width=1
height=1 alt=""></TD>
</TR>
<!-- List items -->
<% for (int c = 0; c <
m_versions.Coun t; ++c) %>
<% { %>
<%
ISPFileVersion ver = (ISPFileVersion )m_versions[c]; %>
<TR>
<TD
class="ms-vb2" valign="top">
<% SPEncode.WriteH tmlEncode(Respo *nse, ver.ID.ToString ()); %>
</TD>
<TD
class="ms-vb-title" valign="top">
<TABLE class="ms-unselectedtitle " onmouseover=OnI tem(this)
cellspacing="0" CTXName="ctxVer "
ItemId=<%SPEnco de.WriteHtmlEnc *odeWithQuote(R esponse,
ver.ID.ToString (),
'"'); %> verId=<% SPEncode.WriteH tmlEncodeWithQu *ote(Response,
ver.ID.ToString (), '"'); %> verUrl=<%
SPEncode.WriteU rlEncodeAsUrlWi *thQuote(Respon se, m_web.Url + "/" +
ver.Url, '"'); %> isCur=<%
SPEncode.WriteH tmlEncodeWithQu *ote(Response,
ver.ID == m_file.UIVersio n ? "1" : "0", '"'); %>>
<TBODY>
<TR>
<TD class="ms-vb" width="100%">
<A onfocus=OnLink( this) href=<%
SPEncode.WriteU rlEncodeAsUrlWi *thQuote(Respon se, m_web.Url + "/" +
ver.Url, '"'); %> onclick="DispDo cItem(this)"><%
SPEncode.WriteH tmlEncode(Respo *nse, SPUtility.Forma tDate(m_web,
ver.Created, SPDateFormat.Da teTime)); %></A>
</TD>
<TD><img style="visibili ty:hidden"
src="../images/blank.gif" width="13" alt=""></TD>
</TR>
</TBODY>
</TABLE>
</TD>
<TD
class="ms-vb2" valign="top">
<% if (ver.CreatedBy != null) %>
<% { %>
<% SPEncode.WriteH tmlEncode(Respo *nse, ver.CreatedBy); %>
<% } %>
</TD>
<TD
class="ms-vb2" valign="top">
<% SPEncode.WriteH tmlEncode(Respo *nse,
SizeConversion( ver.Size)); %>
</TD>
<TD
class="ms-vb2" valign="top">
<% SPEncode.WriteH tmlEncodePreser *veSpaces(Respo nse,
ver.CheckInComm ent); %>
</TD>
<TD class="ms-vb2"
valign="top">
<% Hashtable hash =
ver.Properties; %>
<!-- hash =
ver.Properties; -->
<% hash.Add("First ",
"Hello");%>
<% hash.Add("Secon d",
"World");%>
<% hash.Add("Third ",
"!");%>
<% ICollection keys =
hash.Keys; %>
<% foreach (object key
in keys) %>
<% { %>
<%
Response.Write( SPEncode.HtmlEn *code(key.ToStr ing()) + "
:: " + SPEncode.HtmlEn code(hash[key.T*oString()].ToString()) +
"<BR>");
%>
<% } %>
</TD>
</TR>
<% } %>
</TABLE>
</TD>
</TR>
</TABLE>
<SharePoint:For mDigest runat=server/>
</FORM>
</BODY>
</HTML>