asp.net ScriptManager PageMethods é indefinido
Eu quero chamar métodos estáticos do lado do servidor de JS, então eu decido usar o controle ScriptManager no meu site. Então eu tenho uma página mestra, com essa estrutura:
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="TopLevelMasterPage.Master.cs"
Inherits="Likedrive.MasterPages.TopLevelMasterPage" %>
<!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"
xmlns:fb="http://ogp.me/ns/fb#">
<head runat="server">
<title></title>
<script type="text/javascript">
function getGiftFileUrl() {
function OnSuccess(response) {
alert(response);
}
function OnError(error) {
alert(error);
}
PageMethods.GetGiftFileUrl("hero", 1024, 768, OnSuccess, OnError);
}
getGiftFileUrl();
</script>
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManagerMain"
runat="server"
EnablePageMethods="true"
ScriptMode="Release"
LoadScriptsBeforeUI="true">
</asp:ScriptManager>
<asp:ContentPlaceHolder ID="MainContent" runat="server">
</asp:ContentPlaceHolder>
</form>
</body>
</html>
Mas quando a página está carregando, eu tenho uma exceção JS - o PageMethods é indefinido. Eu supus que esse objeto será criado implícito para que eu possa usá-lo no meu javascript.