Introduction
In this article we will learn How to read session value using javascript. Read session using jquery. Use session in client side using javascript and jquery.
Previous Updates
In previous articles we have learnt what is TypeScript and How to Install this on VS2015 .AngularJS basics, Best basic C# interview questions. Transform multiple rows into one comma separated string column.
Practice
Here i am sharing code through which you can achieve this task in a very easy way. Here is the design page of this example which describe how your page looks like.
Aspx page code
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Read Session Variable Value Using JavaScript or jQuery</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
$(function () {
var value = 'This is the value of
' + ' <%= Session["SessionValue"] %>'
$('#lbldisplaySession').text(value)
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<label id="lbldisplaySession" />
</div>
</form>
</body>
</html>
|
Note - Here i am using cloud reference of jquery library. So you don't need to worry about download and referenced that jquery file.
.Cs page Code
protected void Page_Load(object sender, EventArgs e)
{
Session["SessionValue"] = "My Session";
} |
And now run the application and you have done it.
0 comments:
Post a Comment