'System.Web.HttpUnhandledException'  exception when calling ajax webservices

hijiki7777
hijiki7777 used Ask the Experts™
on
I want to use the cascading dropdown extender.
However I keep getting the above error.
The service path and method are correct, I can display AjaxWebServices.asmx OK and see the methods that can be called.

So why would this not work?
<ajaxToolkit:CascadingDropDown ID="CascadingDropDown1" runat="server"
        TargetControlID="ddlCompany" Category="Company" PromptText="Select a company" 
        ServicePath="AjaxWebServices.asmx" ServiceMethod="GetCompanyLevels"  />

---------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Collections;
using System.Collections.Specialized;
using AjaxControlToolkit;

/// <summary>
/// Summary description for AjaxWebServices
/// </summary>
[WebService(Namespace = "http://mouchel.com/webservices/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// The attribute allows this Web Service to be called from script, using ASP.NET AJAX. 
[System.Web.Script.Services.ScriptService]
public class AjaxWebServices : System.Web.Services.WebService
{
    public AjaxWebServices()    {    }

    [WebMethod]
    public CascadingDropDownNameValue[] GetCompanyLevels(string knownCategoryValues, string category)
    {
        List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();
        IList<Biz.Companies> companies = new Biz.Companies().GetCompanies();
        foreach (Biz.Companies company in companies)
        {
            values.Add(new CascadingDropDownNameValue(company.Company, company.Company_Id.ToString()));
        }
        return values.ToArray();
    }

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Can u handle the above exception using try catch and let us know the exact error.

Author

Commented:
I do not know where to put it.
The webservice method does not get called.
The stack trace does not identify any lines that are causing the problem.
Here is an article which shows how to handle exceptions in web services.
http://www.developer.com/net/csharp/article.php/3088231/Exception-Handling-in-Web-Services

Try to get a hint from it.

Author

Commented:
This article shows how you can put exception handling inside webmethods.
However the breakpoints I have put in the webmethod do not get reached in the first place.
So although this is good practice, it doesn't help me.
The exception is identifying a failure to call the webmethod.
I found the problem was caused by a spelling mistake in the TargetControlID

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial