• ajax.net中操作session


    在服务器端page_load
    AjaxPro.Utility.RegisterTypeForAjax(typeof(test));
    this.Button_Write.Attributes.Add("onclick","WriteSession();");//写session
    this.Button_Read.Attributes.Add("onclick", "ReadSession();");//读session
    其他写和读的方法
    /// <summary>
    /// 写session
    /// </summary>
    /// <param name="str"></param>
    [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
    public void WriteSession(string str)
    {
    Session["UserName"] = str;
    }
    /// <summary>
    /// 读session
    /// </summary>
    /// <returns></returns>
    [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
    public string ReadSession()
    {
    string str = "";
    if (Session["UserName"] != null)
    {
        str = Session["UserName"].ToString();
    }
    return str;
    }


    客户端代码:
     //4、访问Session的值
    //写入
    function WriteSession()
    {
        var str = "HAHA";
        test.WriteSession(str,CallBack_WriteSession);
    }
    function CallBack_WriteSession(res)
    {
        if(res.error == null)
        {
            alert("OK");
        }
        else
        {
            alert(res.error.message);
        }
    }
    //访问
    function ReadSession()
    {
        test.ReadSession(CallBack_ReadSession);
    }
    function CallBack_ReadSession(res)
    {
        if(res.error == null)
        {
            alert(res.value);
        }
        else
        {
            alert(res.error.message);
        }
    }

  • 相关阅读:
    android权限大全
    Java反射经典实例
    SD卡的寄存器 SD总线协议 CRC算法
    ARM CortexM3 操作模式和特权级别
    使用 Printf via SWO/SWV 输出调试信息
    embOS实时操作系统 概览
    embOS实时操作系统 多任务调度
    android wifi hotspot
    Eclipse Java 智能提示
    ARM CortexM3 概览
  • 原文地址:https://www.cnblogs.com/wucf2004/p/582890.html
Copyright © 2020-2023  润新知