Try using ajax call for setting the session value:-
JS:-
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"> </script>
<script type="text/javascript">
var TempSession = '<%= Convert.ToInt32(Session["Status"]) %>';
if (TempSession == 6) {
alert(TempSession);
$.ajax({
type: 'POST',
url: 'WebForm1.aspx/SetValue',
data: '{ val:1 }',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (msg) {
alert("New Session value is " + msg.d);
}
});
}
</script>
In your code behind file:-
[WebMethod]
public static string SetValue(string val)
{
HttpContext.Current.Session["Status"] = val;
return HttpContext.Current.Session["Status"].ToString();
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…