1234567891011121314151617181920...
登録順サンプル
クライアント側からSessionデータを取得する(PageMethods)
このサンプルは、AJAXのPageMethodsを利用して WebサーバーからSession情報を取得します。

061117VB-1.aspx.vb

Protected Overloads Overrides Sub OnLoad(ByVal e As EventArgs) HttpContext.Current.Session("Hello") = "Ajax" End Sub <WebMethod()> _ Public Shared Function GetSession(ByVal key As String) As String Return CType(HttpContext.Current.Session(key), String) End Function

JavaScript

function pageLoad(sender, arg) { PageMethods.GetSession("Hello", onSuccess, onFailure); } function onSuccess(result, userContext, methodName) { alert(result); } function onFailure(error, userContext, methodName) { if(error !== null) { alert(error.get_message()); } }
1234567891011121314151617181920...