473,383 Members | 1,925 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

How to Reference an Existing Hashtable

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>

Nov 17 '05 #1
0 3508

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Vladimir C. | last post by:
Hashtable map = new Hashtable(); map = 10; map = 20; foreach(DictionaryEntry e in map) { e.Value = 100; Console.WriteLine("{0}: {1}", key, map); }
4
by: tham | last post by:
HI can i box and unbox a reference so that i can achieve a 'pointer to pointer' effect. i want to pass a reference as a parameter to a function and then have the function change what the reference...
3
by: A. Burch | last post by:
I posted early about Hashtable use and the shallow/deep copy and storing a reference answered that question. I've got a larger implementation of this, but am not sure why I'm getting this error....
5
by: Fernando Cacciola | last post by:
Hi, I need to produce an ID number that uniquely identifies a given object instance. (If the object is a boxed value, well, it won't really matter, but for _shared_ reference-types I really...
0
by: mnmnm1951 | last post by:
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...
4
by: nate axtell | last post by:
I'm looking for a way to refernce a control by a string that represents the name of the control. I dynamically create some textboxes, labels, and comboboxes each name by a loop iteration index. ...
2
by: Workgroups | last post by:
I need some clarification with the whole "no pointers in VB.NET" thing, because it seems like there are "quazi-pointers" happening but I want to make sure I'm interpreting all this correctly. ...
0
by: Bruce | last post by:
Hi I have a question on using System.Threading.Timer. I understand that in order for the timer to work, I need to store a reference to the timer so that it does not get garbage collected. In my...
5
by: colin | last post by:
Hi, I need to cache various resource objects such as images for example, wich might be referenced from multiple objects (wich could be considered documents for ease of discusion) and the idea is...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.