The code bellow is all I have in a test project (ASP.NET 4.0 +
VB) to test the usage of PageMethods:
<%@ Page Language="
vb" AutoEventWireup="false" CodeBehind="Default.aspx.
vb" Inherits="WebApplication2._Default" %>
<!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 runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" EnablePageMethods="True" runat="server">
</asp:ScriptManager>
<div>
<input id="YourName" type="text" />
<br />
<input id="Button1" type="button" value="Say Hello now" />
<script language="javascript" type="text/javascript">
function HelloWorldC(result)
{
alert(result);
}
function HelloWorldPageMethod()
{
var yourName = $get('YourName').value;
pagemethods.HelloWorld(yourName, HelloWorldC);
}
function HelloWorldCallback(result)
{
alert(result);
}
$addHandler($get('Button1'), 'click', HelloWorldPageMethod);
</script>
</div>
</form>
</body>
</html>
The Config.Web contains:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />
</system.web>
</configuration>
Problem is: it looks like the compiler cannot get a reference to pagemethods. It does not shows in IntelliSence and when I run the application I only receive an erro that says "pagemethods" is not defined.
Any clues?