Click here to Skip to main content
15,915,093 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all ,

I am trying to get the value inside a session from javascript and alerting the value,but the alert is giving "undefined" so what is my mistake ?

Here is my code :

XML
<script runat="server">

       <WebMethod()> _
       Public Shared Function Sessions(ByVal key As String) As String
           Return DirectCast(HttpContext.Current.Session(key), String)
       End Function

   </script>


C#
function pageLoad(sender, arg) {
            Language = PageMethods.Sessions("Lang", OnCallComplete, OnCallError);
        }

        function OnCallComplete(result, userContext, methodName) {
            alert(Language);
        }

        function OnCallError(error, userContext, methodName) {
            if (error !== null) {
                alert(error.get_message());
            }
        }


Please help .
Posted

1 solution

Try using
C#
WebMethod (EnableSession =true)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900