I am struggling to properly reference my web service method with JavaScript on my client page. I keep receiving an error message that says "CalendarHandler is not defined".
<%@ WebService Language="C#" CodeBehind="~/App_Code/CalendarHandler.cs"
Class="CalendarHandler" %>
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master"
AutoEventWireup="true" CodeFile="CalendarPage.aspx.cs" Inherits="CalendarPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
<input type="button" id="loadevents" onclick="callLoadEvents();" />
<div id="eventresults"> </div>
<div id="resultFailed"> </div>
<script language="javascript" type="text/javascript">
var tasks;
function callLoadEvents() {
Speak.CalendarHandler.GetEvents(GetLoadAddress_success, OnFailed);
}
function GetLoadAddress_success(e) {
tasks = e;
}
// --------------------------
function OnFailed() {
$get('resultFailed').innerHTML = "failed";
}
</script>
</asp:Content>
using System.Web;
using System.Web.Services;
[WebService(Namespace = "Speak")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
[System.ComponentModel.ToolboxItem(false)]
public class CalendarHandler : System.Web.Services.WebService
{
static IDictionary<DateTime, String> Calendarevents;//hold my events in this
public CalendarHandler () {
Calendarevents = new Dictionary<DateTime, string>();
Calendarevents.Add(DateTime.Now, "Going to meeting with XYZ Company");
Calendarevents.Add(DateTime.Now.AddDays(1), "XML Class at 2pm");
Calendarevents.Add(DateTime.Now.AddDays(1),"ASP.NET 3.5 Ajax");
Calendarevents.Add(DateTime.Now.AddDays(1),"Pocket Guide");
Calendarevents.Add(DateTime.Now.AddDays(1),"Grocery Shopping");
}
[WebMethod]
public IDictionary<DateTime, String> GetEvents()
{
return Calendarevents;
}
}
If anyone can provide assistance on fixing this issue, it would be greatly appreciated.