2

I have a WCF service in folder "Services":

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.Web.Services;
using System.ServiceModel.Activation;
using System.Web.Script.Services;

namespace Application.Services
{
    [ServiceContract]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    [ScriptService]    
    public class ProductTypeService
    {
        [OperationContract]
        [WebMethod]
        public string LoadMainGridProductType(string test)
        {
            return "Success";
        }
    }
}

and on page I try to call this service method from javascript:

$(document).ready(function () {
    var counter = "test";    
    Application.Services.ProductTypeService.LoadMainGridProductType(counter, ResultLoadMainGridProductType, ErrorLoadMainGridProductType);
});

on page I also make conect to this service and javascript files:

<asp:ScriptManager ID="ScriptManager" runat="server">
            <Scripts>
                <asp:ScriptReference Path="~/Scripts/ProductType.js" />
            </Scripts>
            <Services>
                <asp:ServiceReference Path="~/Services/ProductTypeService.svc" />        
            </Services>
        </asp:ScriptManager>

but code fails on

Application.Services.ProductTypeService.LoadMainGridProductType(counter, ResultLoadMainGridProductType, ErrorLoadMainGridProductType);

Error : Error of implementation of Microsoft Jscript: "Application" is not certain. How fix this???

1

1 Answer 1

1

Firstly, check to see if the WCF service is working correctly by navigating directly to it, e.g. http://localhost:(port-number)/Services/ProductTypeService.svc

I suspect that this wont work and give you some errors.

Secondly, check to make sure that the jsdebug javascript file has been generated and is included in the scripts loaded with the application.

Another person asked a similar question earlier. How get namespace on javascript in asp.net web?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.