很簡單,看代碼,value為session的值
代碼如下:
function GetSession(value) {
var temp;
jQuery.ajax({
type: "POST",
url: "GetSession.aspx",
async: false, //是否ajax同步
data: "s=" + value,
success: function(msg) {
temp = msg;
}
});
return temp;
}
GetSession.aspx頁面
代碼如下:
string sessionName = "";
protected void Page_Load(object sender, EventArgs e)
{
sessionName = Request.Form["s"].ToString();
Response.Write(Session[sessionName]);
Response.End();
}