Reputation: 1043
I am having an image icon which on clicking should navigate to the other page
' <input type="image" id="dataReview_' + templates[i].dataFileKey + '" title="Data Review" src="Images/datareview.png" style="height: 15px; width: 15px" onclick="dataReview_tasks(this); return false;"/>\n' +
In dataReview_tasks() function below
function dataReview_tasks(inputOb)
{
var info = new IOInfo(inputObj);
var id = info.key(0);
var tdLastDateId = "lastRun_" + id;
var decoded_lastRunDate = decodeURIComponent(trim($("#" + tdLastDateId).text())).split(" ")[0];
var lastRunDate = encodeURIComponent(decoded_lastRunDate);
window.location('<%= ResolveUrl("~/GUI/DataReviewNEW.aspx") %>');
I should be making the ID and the lastRunDate as cookies. How can I approach this.
I am not sure why it is not holding the value 54 while I am debugging, I am new Javascript and not sure if I am giving them properly in document.cookie Any help is greatly appreciated
Upvotes: 0
Views: 1859
Reputation: 3726
function dataReview_tasks(inputOb){
var info = new IOInfo(inputObj);
var id = info.key(0);
var tdLastDateId = "lastRun_" + id;
var decoded_lastRunDate = decodeURIComponent(trim($("#" + tdLastDateId).text())).split(" ")[0];
var lastRunDate = encodeURIComponent(decoded_lastRunDate);
var tCookiename = '<%= this.CookieDataFileKey %>'; //This is your '$DataFileKey' placeholder from codebehind
var tCookievalue = {id: id, lastRunDate: lastRunDate}; //Since there are two values, we are passing an object.
//Setting the actual cookie
document.cookie = [tCookiename, JSON.stringify(tCookievalue)].join('=');
window.location('<%= ResolveUrl("~/GUI/DataReviewNEW.aspx") %>')
}
function readCookie(n){
var tC = document.cookie || '';
tS = tC.split(n + '=').pop().split(';')[0];
return JSON.parse(tS)
}
readCookie('$DataFileKey')
Yes, of course the values can be set seperately:
//Settings '$DataFileKey'
document.cookie = ['<%= this.CookieDataFileKey %>', id].join('=');
//Settings '$DataWhatever'
document.cookie = ['<%= this.CookieDateCompleteEnd %>', lastDateRun].join('=');
function readCookie(n){
return (document.cookie || '').split(n + '=').pop().split(';')[0]
}
readCookie('$DataFileKey')
Upvotes: 1
Reputation: 654
Use the code below :
document.cookie = "$(<%= this.CookieDataFileKey %>) =" + id +'"';
Upvotes: 0