Page Methods return undefined javascript error

  • Thread starter Thread starter Fresno Bob
  • Start date Start date
F

Fresno Bob

I have a web method in my page, with Page Methods enabled on
ScriptManager. When I call the function to get a return value my alert box
says undefined. It works if I define a OnSuccess function in JS for my
method. I want to get a return value and feed it to another JS function. I am
quite happy for the calls to be synchronous as one JS function needs a
function from a previous one. This is VS 2008 SP 1 and .net 3.5

<WebMethod()> _
Public Shared Function MyMethod(ByVal name As String) As String
Return "Hello " & name
End Function


<asp:ScriptManager ID="ScriptManager1" runat="server"
EnablePartialRendering="true" EnablePageMethods="True">
</asp:ScriptManager>



window.onload = function() {

alert(PageMethods.MyMethod("Paul Hayman"));

}
 
Back
Top