0

i have made webservice, and i am trying to consume it using javascript, but when i call the webservice method it gives the error Webservice not defined. I have given reference of it .

<asp:ScriptManager ID="ScriptManager1" runat="server">
        <Services>
       <asp:ServiceReference Path="../WebService.asmx" />
    </Services>
       </asp:ScriptManager>

my method

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// 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 WebService : System.Web.Services.WebService
{
    CultureInfo cul = new CultureInfo("gu-IN", true);
    protected sdData s = new sdData();
    protected component comp = new component();
    public ClsVB objvb = new ClsVB();
    DBAccess dbAccess = new DBAccess();

    public WebService()
    {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    public string SubmitDDIPo(string txtCaseNoDDIPO, int txtDDIPO, int txtAmount, string txtDDDate, string txtBank, string District_Code )
    {

javascript method calling

<script type="text/javascript">
            function addDDIPO() {
                "DDIPOdiv".Obctrl().style.display = "block";
                "fadeDiv".Obctrl().style.display = "block";

            }
            function submitDDIPO()
             {
                 WebService.SubmitDDIPo("txtCaseNoDDIPO".Obctrl().value, "txtDDIPO".Obctrl().value, "txtAmount".Obctrl().value, "txtDDDate".Obctrl().value, "txtBank".Obctrl().value, Session["District_Code"].ToString(), ResultSubmitSucess, ResultFailure);
             }
            </script>

Is that something i am missing? please help

5
  • what kind of JS library are you using? By default, WebService is not a JS object. You may want to read this: stackoverflow.com/questions/208051/… Commented Feb 4, 2014 at 6:36
  • Huh? You'd better learn from JavaScript basics, if you don't even know which library you are using. (Hint: to check which library is used, check the scripts you have "included" via <script> tag) Commented Feb 4, 2014 at 6:40
  • @commenters ankitsrist is in a good way with this. See msdn.microsoft.com/en-US/en-en/library/bb398995(v=vs.90).aspx. Commented Feb 4, 2014 at 7:14
  • 1
    ASMX is a legacy technology, and should not be used for new development. WCF or ASP.NET Web API should be used for all new development of web service clients and servers. One hint: Microsoft has retired the ASMX Forum on MSDN. Commented Feb 4, 2014 at 7:22
  • thanks i have done by calling webservice with jquery... Commented Feb 4, 2014 at 10:36

1 Answer 1

3

Try to uncomment [System.Web.Script.Services.ScriptService].

If the uncommneted attribute doesn't work check the namespaces. ScriptManager create the javascript client proxy whith full path. Ej: namespace1.namespace2.WSClassName.Method(). You can also try to put the client proxy inline to see the js source to easyly find it with ServiceReference.InlineScript property.

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.