Actually I am having a requirement like :
I need to get the ID's of checked records by using Javascript and store the id's in a cookie and access that cookie in controller and delete the records based on that id's
My Javascript is :
<script type="text/javascript">
//<![CDATA[
function SelectionChanged(s, e)
{
s.GetSelectedFieldValues("ID", GetSelectedFieldValuesCallback);
}
function GetSelectedFieldValuesCallback(values)
{
SelectedRows.BeginUpdate();
try
{
SelectedRows.ClearItems();
var s = '';
for (var i = 0; i < values.length; i++) {
//SelectedRows.AddItem(values[i]);
s=s+values[i]+',';
}
}
finally
{
document.cookie = s;
}
$("#count").html(gvRowSelection.GetSelectedRowCount());
}
// ]]>
Actually I am having a requirement like :
I need to get the ID's of checked records by using Javascript and store the id's in a cookie and access that cookie in controller and delete the records based on that id's
My Javascript is :
<script type="text/javascript">
//<![CDATA[
function SelectionChanged(s, e)
{
s.GetSelectedFieldValues("ID", GetSelectedFieldValuesCallback);
}
function GetSelectedFieldValuesCallback(values)
{
SelectedRows.BeginUpdate();
try
{
SelectedRows.ClearItems();
var s = '';
for (var i = 0; i < values.length; i++) {
//SelectedRows.AddItem(values[i]);
s=s+values[i]+',';
}
}
finally
{
document.cookie = s;
}
$("#count").html(gvRowSelection.GetSelectedRowCount());
}
// ]]>
Share
Improve this question
asked Dec 14, 2012 at 4:20
user1859953user1859953
11 silver badge5 bronze badges
2 Answers
Reset to default 4I'm not exactly sure what your question is specifically, but if you're looking for a way to set cookies via Javascript, check out the jquery-cookie plugin. You'd access it in your controller just like you would any other cookie:
Javascript
$.cookie('mycookie', 'myvalue');
C#
Request.Cookies["mycookie"].Value;
I think Scott was rigth except that you need to Base64 decode the data then JSON decode the data.
JavaScript
$.jCookies({name:'user',value:{name:'brian',level:'awesome'}});
C#
Convert.FromBase64String(Page.Request.Cookies["user"].Value)
For more information look at the following Page: Here