Note that there are some explanatory texts on larger screens.

plurals
  1. POPage Methods throwing Undefined
    text
    copied!<p>I am trying to use page methods to call a function and I am getting a "PageMethods is undefinded" error. I have used them before whilst using C# but not VB so I'm wondering if my syntax is wrong as all examples I can find are C#. I am also wondering if it's because my scriptmanager is on the master page?</p> <p>I've read about this error everywhere but everything I have appears to be correct!</p> <p>Can anyone point me at what I am doing wrong?</p> <p>Thanks!</p> <p>My code:</p> <p><strong>Part of Master Page</strong></p> <pre><code>&lt;form id="form1" runat="server"&gt; &lt;asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" EnablePageMethods="true" &gt; &lt;/asp:ScriptManager&gt; &lt;div id="header"&gt;~~~~~ </code></pre> <p><strong>Content Page HTML</strong></p> <pre><code> &lt;asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"&gt; &lt;script type="text/javascript"&gt; function selectZones(commaSeparatedList){ PageMethods.Zones(commaSeparatedList); } &lt;/script&gt; &lt;/asp:Content&gt; &lt;asp:Content ID="Content2" ContentPlaceHolderID="navigationPlaceHolder" runat="server"&gt; &lt;/asp:Content&gt; &lt;asp:Content ID="Content3" ContentPlaceHolderID="ContentBodyPlaceHolder" runat="server"&gt; &lt;a href='' onclick='selectZones("blah,blah,blah"); return false;'&gt;click here&lt;/a&gt; &lt;/asp:Content&gt; &lt;asp:Content ID="Content4" ContentPlaceHolderID="functionsMenuPlaceHolder" runat="server"&gt; &lt;/asp:Content&gt; </code></pre> <p><strong>Content Page Code Behind</strong></p> <pre><code> Imports System.Web.Services Public Class TestClass Inherits BaseClass Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load End Sub &lt;WebMethod()&gt; Protected Shared Sub Zones(ByVal zones As String) HttpContext.Current.Response.Write("test = " &amp; zones) End Sub End Class </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload