我创建了Web服务并尝试通过启用其“ScriptService”属性从java脚本调用它。但是我收到控制台错误“Uncaught ReferenceError:AutoFill not defined”我在脚本管理器中注册了它的引用,但没有运气。
AutoFill.asmx
namespace eService
{
/// <summary>
/// Summary description for AutoFill
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class AutoFill : WebService
{
[WebMethod(EnableSession = true)]
public string DismissAlertNotification(int ID, int CompanyID, string SectionName)
{
}
header.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="header.ascx.cs" Inherits="ePrint.Templates.header" %>
<asp:ScriptManagerProxy ID="smproxy" runat="server">
<Services>
<asp:ServiceReference Path="~/EprintService/AutoFill.asmx" />
</Services>
</asp:ScriptManagerProxy>
<script type="text/javascript" language="javascript">
function dismiss_alert_notification(ID, CompantID, SectionName) {
AutoFill.DismissAlertNotification(ID, CompantID, SectionName, onResponse);
}
</script>