I'm most curious to find out if PageMethods works if there's a Master Page involved. I tried implementing the sample code from this page as follows:
<%@ Page Language="C#" MasterPageFile="~/main.master" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" %>
<%@ Import Namespace="System.Web.Services" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server" EnableViewState="true">
<Scripts>
<asp:ScriptReference Path="PageMethod.js"/>
</Scripts>
</asp:ScriptManagerProxy>
<script runat="server">
[WebMethod]
// Get session state value.
public static string GetSessionValue(string key)
{
return (string)HttpContext.Current.Session[key];
}
[WebMethod]
// Set session state value.
public static string SetSessionValue(string key, string value)
{
HttpContext.Current.Session[key] = value;
return (string)HttpContext.Current.Session[key];
}
</script>
<h2>Using Page Methods with Session State</h2>
<center>
<table>
<tr align="left">
<td>Write current date and time in session state:</td>
<td>
<input type="Button"
onclick="SetSessionValue('SessionValue', Date())"
value="Write" />
</td>
</tr>
<tr align="left">
<td>Read current date and time from session state:</td>
<td>
<input type="Button"
onclick="GetSessionValue('SessionValue')"
value="Read" />
</td>
</tr>
</table>
</center>
<hr/>
<span style="background-color:Aqua" id="ResultId"></span>
</asp:Content>
But no matter what I do, I keep on getting some variation of a Javscript "object missing" error. Might anybody know why?
Robert W.