I have another task at hand. I need to use cookies to read a title of an item from a custom list in SharePoint. This task is for SharePoint 2010.
I have a container set up that will display the two newest items. This container is being populated by a usercontrol and is using the ASP:Repeater control. In this control I have this:
<
asp:Literal ID="Literal1" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Portal Content") %>' /> <asp:HyperLink ID="hlAssetUrl" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Asset Title") %>' NavigateUrl='<%# DataBinder.Eval(Container.DataItem, "Asset URL") %>' Target='<%# Convert.ToString(Convert.ToBoolean(DataBinder.Eval(Container.DataItem, "Open in New Window")) ? "_blank" : "_top") %>' >
I am trying to set the Asset title in the hyper link as the cookie.
I have the GetCookie function and SetCookie function as follows:
unction SetCookie(cookieName, cookieValue, nDays) {
var today = new Date();
var expire = new Date();
if (nDays == null || nDays == 0) nDays = 1;
expire.setTime(today.getTime() + 3600000*24*nDays);
document.cookie = cookieName + "=" + escape(cookieValue)
+ ";expires=" + expire.toGMTString();
}
function ReadCookie(cookieName) {
var theCookie = " " + document.cookie;
var ind = theCookie.indexOf(" " + cookieName + "=");
if (ind == -1) ind = theCookie.indexOf(";" + cookieName + "=");
if (ind == -1 || cookieName == "") return "";
var ind1 = theCookie.indexOf(";", ind + 1);
if (ind == -1) ind1 = theCookie.length;
return unescape(theCookie.substring(ind + cookieName.length + 2, ind1));
}
Any lead way would be greatly appreciated.