जगदीश खोलिया: Accessing & Assigning the Session Variable using Javascript

Monday, February 17, 2014

Accessing & Assigning the Session Variable using Javascript

Assigning the ASP.NET Session Variable using Javascript:
<script type="text/javascript">
function SetUserName()
{
    var userName = "Jagdish Kholiya";
    '<%Session["UserName"] = "' + userName + '"; %>';
     alert('<%=Session["UserName"] %>');
}
</script>
Accessing ASP.NET Session variable using Javascript:
<script type="text/javascript">
    function GetUserName()
    { 
        var username = '<%= Session["UserName"] %>';
        alert(username );
    }
</script>
Post a Comment