I add in my project WCF service (ProductService.svc in forder Services):
using System; using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.ServiceModel.Activation; using System.ServiceModel.Web; using System.Web.Services; using System.Collections.Generic; namespace Application.Services { [ServiceContract(Namespace = "")] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] public class ProductService { [WebMethod] [OperationContract] public static string GetMainGridProductHtml() { return "Helo World :)"; } } } And try to call service from javascript file:
<script type="text/javascript"> Application.Services.ProductService.GetMainGridProductHtml(ResultLoadTableMainGridHtml, ErrorLoadTableMainGridHtml); function ResultLoadTableMainGridHtml(html) { debugger; alert("Ok"); } function ErrorLoadTableMainGridHtml() { debugger; alert("Error"); } function NewAddBtn() { debugger; alert("Yuppi"); } </script> It won't work: Microsoft JScript runtime error: 'Application' is undefined How can I manage this?
asp:ScriptManagerwith aasp:ServiceReferenceon the page?