AJAX中CascadingDropDownExtender的方法错误500

时间:2009-06-22 12:16:26

标签: c# ajax

我正在使用AJAX中的CascadingDropDownExtender。当我运行示例时,我在下拉列表中收到“[Method Error 500]”。我写了一个Web服务(carService.asmx)来从XML(carService.xml)获取值到Dropdown中。甚至Web服务也没有正确调用。当我运行Web服务时,会生成一个包含错误的XML。请帮我解决这个问题。感谢。

3 个答案:

答案 0 :(得分:0)

开始调试您的网络服务。看起来就像问题所在。看看这篇微软文章:http://support.microsoft.com/kb/311766

答案 1 :(得分:0)

答案迟到了,但它可以帮助其他人。

我有一个类似的问题,但最初我得到的是“方法错误415”,然后是“方法错误500”。我建议检查你的web服务绑定。

我意识到我偶然将服务添加为启用Silverlight的服务而不是启用AJAX的服务。我最终重做了web.config中的服务绑定,这导致了“方法错误500”。显然我错误地修改了服务绑定,而是最终重新创建了服务,但是作为AJAX启用服务。事后,一切都按预期进行。

P.S。 我正在使用WCF服务,但我确信这同样适用于普通的Web服务。

答案 2 :(得分:0)

Sorry for late answer  i think this will help in future who w'll get this error in ajax cascadedropdown for error 500 is solved for me this error because of changing parameter values for the binding method as clearly showed below

** Initially **

public CascadingDropDownNameValue[] BindCountrydropdown(string value, string text)
    {
        SqlConnection concountry = new SqlConnection(ConfigurationManager.ConnectionStrings["Connection"].ConnectionString);
        concountry.Open();
        SqlCommand cmdcountry = new SqlCommand("select * from tbl_Countries", concountry);
        SqlDataAdapter dacountry = new SqlDataAdapter(cmdcountry);
        cmdcountry.ExecuteNonQuery();
        DataSet dscountry = new DataSet();
        dacountry.Fill(dscountry);
        concountry.Close();
        List<CascadingDropDownNameValue> countrydetails = new      List<CascadingDropDownNameValue>();
        foreach(DataRow dtrow in dscountry.Tables[0].Rows)
        {
            string CountryID = dtrow["IDCountry"].ToString();
            string CountryName = dtrow["CountryName"].ToString();
            countrydetails.Add(new CascadingDropDownNameValue(CountryName,CountryID));
        }
        return countrydetails.ToArray();
    }


i got error 500 i found solution because of changing parmeter name in above method solution is given below u must pass parmaters as(knownCategoryValues,category) don't change parameter name

** Solution **
  public CascadingDropDownNameValue[] BindCountrydropdown(string knownCategoryValues, string category)
    {
        SqlConnection concountry = new  SqlConnection(ConfigurationManager.ConnectionStrings["Connection"].ConnectionString);
        concountry.Open();
        SqlCommand cmdcountry = new SqlCommand("select * from tbl_Countries", concountry);
        SqlDataAdapter dacountry = new SqlDataAdapter(cmdcountry);
        cmdcountry.ExecuteNonQuery();
        DataSet dscountry = new DataSet();
        dacountry.Fill(dscountry);
        concountry.Close();
        List<CascadingDropDownNameValue> countrydetails = new List<CascadingDropDownNameValue>();
        foreach(DataRow dtrow in dscountry.Tables[0].Rows)
        {
            string CountryID = dtrow["IDCountry"].ToString();
            string CountryName = dtrow["CountryName"].ToString();
            countrydetails.Add(new CascadingDropDownNameValue(CountryName,CountryID));
        }
        return countrydetails.ToArray();
    }

i think this will help for u