I am getting this error 'Microsoft JScript runtime error: 'wsWeatherFeed' is undefined. It's just a basic call to a webservice via the asp:ScriptManager tag. Can someone help me point out what I might be doing wrong?
.Aspx file:
<scriptlanguage="javascript"type="text/javascript">
function fnImgMouseOver(e){
wsWeatherFeed.set_timeout(40000);
wsWeatherFeed.fnGetWeatherData(e,callback_fnImgMouseOver,fnGetWeatherDataError);
}
function callback_fnImgMouseOver(result){
alert(result);
}
function fnGetWeatherDataError(err){alert("Here is the error: " + err.error);
}
</script>
<further down>
<asp:ScriptManagerID="ScriptManager1"runat="server">
<Services>
<asp:ServiceReferencePath="wsWeatherFeed.asmx"/>
</Services>
</asp:ScriptManager>
.Asmx file
<%@dotnet.itags.org.WebServiceLanguage="C#"CodeBehind="~/App_Code/wsWeatherFeed.cs"Class="wsWeatherFeed" %>
.cs WebService file:
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Collections;
using System.Xml;
using System.Xml.XPath;
using System.Xml.Xsl;
[WebService(Namespace ="http://tempuri.org/")][WebServiceBinding(ConformsTo =WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService()]
publicclasswsWeatherFeed :WebService {
public wsWeatherFeed () {//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]protectedstring fnGetWeatherData(String strData)
{
return strData
}
}
I got this to work with VB.Net but I guess I just lost something along the way, can anyone provide a clue?
J
Ok I got it. The reason why my js couldnt get to my webservice class was that my web service method fnGetWeatherData was intially set to 'protected' instead of 'public'.
Anyway, I didnt want anyone to spend any time troubleshooting this if I can answer it quick enough myself.
J
No comments:
Post a Comment