$(function() {  
    $("#menu li a").click(function() {
        $("#content").empty();
        var navId = $(this).attr("id");
        $.getScript("../、、、/、、、/" + navId.substring(4, navId.length) + ".js");        
        setLocation(navId);   
    });
    
    var location = getLocation();        
    $("#" + location).trigger("click");
});

function getLocation() {
    var location = "nav_basicInfo";
    $.ajax({
        type: "Post",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        url: "Index.aspx/GetLocation",
        async: false,
        data: "{}",
        success: function(data) {
            if (data.d != null) {
                location = data.d;
            }
        }
    });
    return location;
}

function setLocation(location) {    
    $.ajax({
        type: "Post",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        url: "Index.aspx/SetLocation",
        data: "{'location':'" + location + "'}",
        success: function(data) { }
    });
}

using System.Web.Services;

[WebMethod(EnableSession = true)]
    public static void SetLocation(string location)
    {
        HttpContext.Current.Session["location"] = location;
    }

    [WebMethod(EnableSession = true)]
    public static string getLocation()
    {
        if (HttpContext.Current.Session["location"] != null)
        {
            return HttpContext.Current.Session["location"].ToString();
        }
        return null;
    }

posted on 2013-04-10 15:43  叶城宇  阅读(144)  评论(0编辑  收藏  举报