I'm having trouble with the sample below since moving from Atlas to AJAX.
I've done a LOT of research with prototypes and delegates, but I cant get
this simple, "class-like" example to work.
Any help greatly appreciated. Thanks in advance.
============ASPX PAGE=============
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="test.aspx.vb"
Inherits="WebApplication1.test" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager runat="server" ID="ScriptManager1">
<Services>
<asp:ServiceReference Path="WS1.asmx" />
</Services>
</asp:ScriptManager>
<input type='button' value='Click me' id='myButton'
onclick='doThis(778899)' />
</form>
</body>
</html>
<script type="text/javascript">
function doThis( MyNumber ){
var tmpOjb = new MySampleClass( MyNumber );
tmpOjb._StartMyFunction();
tmpOjb = null;
}
MySampleClass = function( MyNumber )
{
this._MyNumber = MyNumber;
this._StartMyFunction = function()
{
// This WORKS, but with asyncronous call, this._MyNumber is lost
when _MyReturnHandler is run
/* */
WebApplication1.WS1.HelloWorld(
this._MyNumber,
this._MyReturnHandler);
/* */
// This DOES NOT WORK anymore, but DID with Atlas..
// How can I get this to work again??
/*
WebApplication1.WS1.HelloWorld(
this._MyNumber,
{onMethodComplete: Function.createDelegate(this,
this._MyReturnHandler)});
*/
}
this._MyReturnHandler = function(result)
{
alert(result + "::::" + this._MyNumber);
}
};
</script>
============ASMX PAGE=============
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Text
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.ComponentModel
<System.Web.Services.WebService(Namespace:="http ://tempuri.org/")_
<System.Web.Services.WebServiceBinding(ConformsTo: =WsiProfiles.BasicProfile1_1)>
_
<System.Web.Script.Services.ScriptService()_
<ToolboxItem(False)_
Public Class WS1
Inherits System.Web.Services.WebService
<WebMethod()_
Public Function HelloWorld(ByVal myNumber As String) As String
Return "Hello World [" & myNumber & "]"
End Function
End Class