使用页面方法在javascript中获取会话不起作用? [英] Getting the session in javascript using page methods is not working ?

查看:39
本文介绍了使用页面方法在javascript中获取会话不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在尝试从javascript中获取会话中的值并提醒该值,但警告给出的是未定义",那么我的错误是什么?

这是我的代码:

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 :

<script runat="server">

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

   </script>





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 .

推荐答案

尝试使用
WebMethod (EnableSession =true)


这篇关于使用页面方法在javascript中获取会话不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆