I asked this question a couple of weeks ago and a couple of people who posted replies didn't follow up so I'm still seeking a solution.
I have a very simple web service that I want to make a callback to
(from a ScriptManager). At this stage all it returns is the
out-of-the-box Hello World string.
Here is the full code for the web service and the page which I'm
trying to call it from. I use a Master Page but I can't see that
there's anything on the Master Page which would upset the workings of
what I'm trying to achieve so I'll leave it for now (unless you
specifically ask to see it - it contains only layout/design markup).
The web service:
using System;
using System.Data;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.ComponentModel;
namespace andrewWebsite
{
[WebService(Namespace = http://tempuri.org/)]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService()]
public class DataService : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}
}
And the page itself:
<%@ Page Language="C#" MasterPageFile="~/andrewWebsite.Master" Title="Web Service Test" CodeBehind="test.aspx.cs" Inherits="andrewWebsite.test" %>
<asp:Content ID="main" ContentPlaceHolderID="mainContent" runat="server">
<script type="text/javascript">
<!--
function useService()
{
ret = DataService.HelloWorld(OnComplete, OnTimeOut, OnError);
}
function OnComplete(retResult)
{
alert(retResult);
}
function OnTimeOut(retResult)
{
alert('Timeout');
}
function OnError(retResult)
{
alert('Error');
}
// -->
</script>
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">
<Services>
<asp:ServiceReference Path="DataService.asmx" />
</Services>
</asp:ScriptManager>
<input id="Button1" type="button" value="button" onclick="useService()" />
</asp:Content>
The code-behind file is empty except for the default stuff.
So when I click Button1 I'm expecting to see a message box saying "Hello World". Can you shed any light as to why this isn't occurring?