Introduction:
Here
I will explain simple jQuery code to get /
access asp.net
session variable value in jQuery or how to access
or get session variable value using jQuery in asp.net.
Description:
In
previous articles I explained many articles relating to JQuery, JavaScript, asp.net. Now I will explain how to access or get session variable
value using jQuery
in asp.net.
Get
or Access Session Variable value in jQuery
To
get or access session variable value in jQuery we need to write
the code like as shown below
var name = '<%= Session["UserName"] %>'
|
In above code Session["UserName"]
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 name = '<%= Session["UserName"] %>'
$('#lbltxt').text(name)
});
</script>
</head>
<body>
<label id="lbltxt"
/>
</body>
</html>
|
0 comments :
Post a Comment