CascadingDropDown错误

我试图让我的级联组合框工作,但我得到[方法错误500]。有任何想法吗?我在线搜索,代码应该工作....提前感谢您的帮助! ADDSTORY.ASPX:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="addstory.aspx.cs" Inherits="addstory" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
...
<form id="form1" runat="server">
<asp:ToolkitScriptManager ID="ScriptManager1" runat="server" />
...
<td class="style3">
                <asp:DropDownList ID="selectproject" runat="server" Width="225"></asp:DropDownList>
                <asp:CascadingDropDown ID="ccd1" runat="server"
                ServicePath="~/dropdown.asmx?company=<%=co_id %>" ServiceMethod="GetProjects"
                TargetControlID="selectproject" Category="Project"
                PromptText="Select Project" />
                </td>

            </tr>

            <tr>
            <td class="style3"></td>
            <td width = "150" class="style3">Iteration:</td>

            <td class="style3">
                <asp:DropDownList ID="selectiteration" runat="server" Width="225"></asp:DropDownList>
                <asp:CascadingDropDown ID="ccd2" runat="server"
                ServicePath="~/dropdown.asmx?company=<%=co_id %>" ServiceMethod="GetIterations"
                TargetControlID="selectiteration" Category="Iteration"
                PromptText="Select Iteration" />
                </td>

            </tr>
DROPDOWN.ASMX:
using System.Web.Script.Services;
using AjaxControlToolkit;
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Data.SqlClient;

/// <summary>
/// Summary description for WebService
/// </summary>
[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 dropdown : System.Web.Services.WebService
{
private string GetConnectionString()
{
    return System.Configuration.ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString;
}

[WebMethod]

public CascadingDropDownNameValue[] GetProjects(string knownCategoryValues, string category)
{

    string co_id = this.Context.Request.QueryString["company"].ToString();

    SqlConnection conn = new SqlConnection(GetConnectionString());
    conn.Open();
    SqlCommand comm = new SqlCommand("Select ProjectName, ProjectID FROM Project WHERE CompanyID = '" + co_id + "'", conn);
    SqlDataReader dr = comm.ExecuteReader();
    List<CascadingDropDownNameValue> l = new List<CascadingDropDownNameValue>();
    while (dr.Read())
    {
        l.Add(new CascadingDropDownNameValue(dr["ProjectName"].ToString(), dr["ProjectID"].ToString()));
    }
    conn.Close();
    return l.ToArray();
}

[WebMethod]

public CascadingDropDownNameValue[] GetIterations(string knownCategoryValues, string category)
{
    int ProjectID;
    StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);

    if (!kv.ContainsKey("Project") || !Int32.TryParse(kv["Project"], out ProjectID))
    {
        throw new ArgumentException("Couldn't find project.");
    };

    SqlConnection conn = new SqlConnection(GetConnectionString());
    conn.Open();
    SqlCommand comm = new SqlCommand("SELECT Select CONVERT(VARCHAR(10), StartDate, 103) + ' - ' + CONVERT(VARCHAR(10), EndDate, 103) AS Iteration, ProjectIterationID FROM Iterations WHERE ProjectID=@ProjectID", conn);

    comm.Parameters.AddWithValue("@ProjectID", ProjectID);
    SqlDataReader dr = comm.ExecuteReader();
    List<CascadingDropDownNameValue> l = new List<CascadingDropDownNameValue>();

    while (dr.Read())
    {
        l.Add(new CascadingDropDownNameValue(dr["Iteration"].ToString(), dr["ProjectIterationID"].ToString()));
    }
    conn.Close();
    return l.ToArray();
}

}
    
已邀请:
我发现您已将服务标记为ScriptService,但是您忘记使用
[ScriptMethod]
属性标记各个方法。 同样在级联下拉控件的服务路径属性中,我会取出
~
并使用
/dropdown.asmx
    

要回复问题请先登录注册