Introduction:
Sometime while working with ASP.NET and jQuery, it is need
to use session value at client side i.e. using jQuery or javascript. We can get
session value at client side.
In this article I will explain
how to get value of session on client side using jQuery.
Following method is used to get Value of session in jQuery:
<script type="text/javascript">
$(function() {
var name = '<%=
Session["Name"] %>'
$('#lblName').text(name)
});
</script>
Full Source Code of sample
Application:
Design your page as given
Below(With jQuery script in head section)
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
$(function() {
var name = '<%=
Session["Name"] %>'
$('#lblName').text(name)
});
</script>
</head>
<body>
<label id="lblName'" />
</body>
</html>
0 comments:
Post a Comment