Home > Articles > .Net Framework Articles > How to access Session variables using Javascript in asp.net ?

How to access Session variables using Javascript in asp.net ?

by John Prathip   on Oct 09, 2015   Category: .Net Framework  | Level: Beginner  |  Views: 1334    |  Points: 100   
Like this article? Bookmark and Share:
Accessing & Assigning the Session Variable using Javascript:

Assigning the ASP.NET Session Variable using Javascript:


<script type="text/javascript">

function SetUserName()

{

    var username ="John Prathip";

    '<%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>



Like this article? Bookmark and Share:

Most viewed Articles

User Comments


No response found, be the first to review this article.

Submit feedback about this article

Please sign in to post feedback

Latest Posts