1
PageMethods
を使用してクライアントサイドからサーバー側の関数を呼び出し、JavaScriptの関数の戻り値にアクセスできますか?ここでは例です:クライアント側(JavaScript)のサーバー側(VB.NET)からの戻り値はどのように使用しますか?
クライアント側:
function onBlur(){ //this function is called when you click away from a textbox
PageMethods.SomeServerSideFunction(params, onSuccess, onFailure);
}
function onSuccess(){
//do something on success
//I want to be able to print out the server side function's return value here
alert(PageMethods.DoesItWork(params)) //this is what I've tried, but it doesn't work
}
function onFailure(){
//do something on failure
}
サーバーサイド:簡単に言えば
<System.Web.Services.WebMethod()>
Public Shared Function DoesItWork(params As String) As Boolean
'logic to determine a return value
Dim RetVal as Boolean
Return RetVal 'I want to be able to use this return value on the client side
End Function
、私はちょうど上のサーバー側の関数の戻り値にアクセスできるようにする必要がありますクライアント側。前もって感謝します。
これは働いていましたの!ありがとう! – ic3man7019