Visual Basic .NET » ASP.NET General Discussion
Simple add method not working -- bubberz --


I've got this in the html head of my page, Ajax.aspx:

<script language="javascript">
window.onload = function () {

var response = Ajax.Add(6, 9);
alert(response.value);
}

For the code behind I've got:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AjaxPro.Utility.RegisterTypeForAjax(GetType(Ajax))
End Sub

<AjaxPro.AjaxMethod()> _
Public Function Add(ByVal firstNumber As Integer, ByVal secondNumber As Integer) As Integer
Return firstNumber + secondNumber End Function

I'm getting "Object does not support this property or method" for the line:
var response = Ajax.Add(6, 9);

-- INeedADip --


Make sure you are using the correct namespace....

There error is telling you that "Ajax.Add" does not exist.
If you are using a Web Application called "MyApp", your call would more than likely be MyApp.Ajax.Add()

Look at the source in Fiddler for that particular .ashx file..

-- bubberz --


INeedADip,

Thanks again for the help!

That was it. This book specificially says to do "Page Class".Add(......, and doesn't say anything about using the web app name.

You were right though, this worked (CSS is the app name):
<script language="javascript">
window.onload = function () {

var response = CSS.Ajax.Add(6, 9);
alert(response.value);
}

[Submit Comment]Home