Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want that my session value check in javascript and if the value is 1 the html button should be invisible in page and if value is 0 the button will be visible
Posted

1 solution

In C# code you need to write something like:
Session["myValue"] = 1;

In JavaScript you can access the value is stored in session by writing like:
var yourSessionValue = '<%= Session["myValue"] %>';
  alert(yourSessionValue);
 
Share this answer
 
v2
Comments
Member 10700420 26-Mar-14 7:11am    
how i make my button invisible by comparing with session value
Snesh Prajapati 26-Mar-14 7:25am    
If you are using jQuery also then you can write as given below:
$(document).ready(function () {
var yourSessionValue = '<%= Session["myValue"] %>';
if (yourSessionValue == 1) {
$("#btnSubmit").hide();
}
else {
$("#btnSubmit").show();
}
});
Snesh Prajapati 26-Mar-14 7:29am    
If you want to achieve the same using JavaScript visit below link:
http://jsfiddle.net/z98NS/
Kumar_Jitendra 27-Mar-14 14:54pm    
What if we write below:

var yourSessionValue = '<%= Session["myValue"] %>';

<%
Session["myValue"] = null;
%>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900