title: using web methods with master pages
body: <p>I've got a function on all pages in my site which is located in my master page and I want it to run from some jQuery Ajax method.</p>
  
  <p>I've got some code like this at the moment</p>
  
  <p>jQuery</p>
  
  <pre><code>$(document).ready(function() {
    $("#test").click(function() {
      $.ajax({
        type: "POST",
        url: "Default.aspx/GetDate",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(msg) {
          $("#test").text(msg.d);
        }
      });
    });
  });
  </code></pre>
  
  <p>HTML in Master page</p>
  
  <pre><code>&lt;div id="test"&gt;Click here for the time.&lt;/div&gt;
  </code></pre>
  
  <p>Asp.Net code behind in my Master VB</p>
  
  <pre><code>&lt;WebMethod&gt; _
  Public Shared Function GetDate() As String
      Return DateTime.Now.ToString()
  End Function
  </code></pre>
  
  <p>Currently this doesn't work unless I move the web method to the <code>Default.aspx</code> VB page</p>
  
  <p>Is there a way I can change this part</p>
  
  <pre><code>url: "Default.aspx/GetDate",
  </code></pre>
  
  <p>To use the master page function?</p>
  
  <p>I tried changing it to </p>
  
  <pre><code>url: "template.master/GetDate",
  </code></pre>
  
  <p>But this just gives me a 404 error</p>
  
  <p>Any ideas?</p>
  
  <p>Thanks in advance</p>