Hi,
Its working now, i resolved the problem like this:
Inserted the Script in the Header
<script type="text/javascript">
$(document).ready(function () {
$("#btnCalculate").click(function () {
var num1 = $('#txtFirstNumber').val();
var num2 = $('#txtSecondNumber').val();
$.ajax({
type: "POST",
dataType: "json",
contentType: "application/json; charset=utf-8",
url: '<%= Page.ResolveUrl("~/webMethods.aspx/CalculateSoma")%>',
data: "{'Num1':'" + num1 + "', 'Num2':'" + num2 + "'}",
success: function (Result) {
$('#dvMsg').text("Sum of " + num1 + " and " + num2 + " = " + Result.d);
},
error: function (xhr, textStatus, error) {
$('#dvMsg').text("Error:" + error);
}
});
return false;
});
});
</script>
<asp:ScriptManager runat="server" EnablePageMethods="true"/> next to <form runat="server">
Created an aspx file named "webMethods.aspx" that contains this code in code behind:
[WebMethod(EnableSession = true)]
public static string CalculateSoma(int Num1, int Num2)
{
int Result = Num1 + Num2;
return Result.ToString();
}
In App_Code > RouteConfig.cs file, had to change:
settings.AutoRedirectMode = RedirectMode.Permanent
to
settings.AutoRedirectMode = RedirectMode.Off;
Thank you all for the pointers.
Paulo Nóbrega