Friday 4 October 2013

How to get session variable value using Jquery in asp.net


In this article I will explain How to get session variable value using Jquery in asp.net?

Get Session Variable value in jQuery

To get session variable value in Jquery we need to write the code like as shown below

var FirstName = '<%= Session["UserID"] %>'

In above code Session["UserID"] is the value what we set in session. If you want to see it in complete example check below code


<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
$(function() {
var FirstName '<%= Session["UserID"] %>'
$('#lbltxtFirstName').text(FirstName)
});
</script>
</head>
<body>
<label id="lbltxtFirstName" />
</body>
</html>


No comments:

Post a Comment