【问题标题】:Assigning Session variable from Javascript从 Javascript 分配 Session 变量
【发布时间】:2013-08-08 17:13:15
【问题描述】:

大家好,我正在使用 Javascript 分配一个 Session 变量,如下所示,我正在使用 devexpress 控件

<script type="text/javascript">
    function f() {
        var v = textBox1.GetValue();
        <%Session["Demo"] = v;%>
        var sValue='<%=Session["Demo"]%>';
        textBox3.SetValue(sValue);
    }
</script>

当我以The name 'v' does not exist in the current context 运行时,网页上出现错误

那么有人可以帮我做什么

【问题讨论】:

  • 做不到,JS在客户端执行。

标签: javascript asp.net session


【解决方案1】:

正如@The New Idiot 提到的 - 它不能在客户端完成,因为 Session 对象存储在服务器端。您可以做到的唯一方法是在某些请求 get/post 甚至 ajax 请求并在服务器端设置变量

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-08-31
    • 1970-01-01
    • 2010-12-28
    • 2023-03-26
    • 1970-01-01
    • 2018-06-02
    • 1970-01-01
    相关资源
    最近更新 更多