我想写一个Confirm弹出框的静态函数,思路是用js把confirm返回的值放到cookie里面,然后C#获取,函数代码如下
bool Rst = false;
Write("document.cookie='Rst='+confirm('" + msg + "'); ");
Msg(HttpContext.Current.Request.Cookies["Rst"].Value);
if (HttpContext.Current.Request.Cookies["Rst"] != null)
{
try
{
Rst = bool.Parse(HttpContext.Current.Request.Cookies["Rst"].Value);
Msg(Rst.ToString());
}
catch { Msg("cookie获取失败"); }
finally
{
}
}
else { Msg("cookie写入失败"); }
return Rst;但是每次获取的cookie值都是上一次js写入的值,就是第一次弹出"cookie获取失败",以后每次都是上次写入的值。
求高手解答一下,折腾我一天了,由于我是想写出类以后直接调用,故不要用隐藏域或者request这样的方法~~
bool Rst = false;
Write("document.cookie='Rst='+confirm('" + msg + "'); ");
Msg(HttpContext.Current.Request.Cookies["Rst"].Value);
if (HttpContext.Current.Request.Cookies["Rst"] != null)
{
try
{
Rst = bool.Parse(HttpContext.Current.Request.Cookies["Rst"].Value);
Msg(Rst.ToString());
}
catch { Msg("cookie获取失败"); }
finally
{
}
}
else { Msg("cookie写入失败"); }
return Rst;但是每次获取的cookie值都是上一次js写入的值,就是第一次弹出"cookie获取失败",以后每次都是上次写入的值。
求高手解答一下,折腾我一天了,由于我是想写出类以后直接调用,故不要用隐藏域或者request这样的方法~~
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货