带有Web服务的Ajax级联下拉列表在服务器上不起作用,列表为空



我需要ajax级联下拉列表的帮助,它在我的本地计算机上完美地工作,但当我在服务器上部署它时,所有下拉列表都是空的,没有任何错误消息!有人能帮帮我吗?我的代码是:'

                            <ajaxToolkit:CascadingDropDown ID="code_CascadingDropDown" 
                                runat="server" TargetControlID="code" LoadingText="Loding ..."
                                PromptText="Select Code" ServiceMethod="GetCodes" ServicePath="~/WebService.asmx"
                                Category="Code" UseContextKey="True" Enabled="true">
                            </ajaxToolkit:CascadingDropDown>
                            &nbsp;&nbsp;
                            <asp:DropDownList ID="type" runat="server" BackColor="White" Height="22px" 
                            TabIndex="5" Width="170px" >
                                <asp:ListItem></asp:ListItem>
                            </asp:DropDownList>
                            <ajaxToolkit:CascadingDropDown ID="type_CascadingDropDown" 
                                runat="server" TargetControlID="type" Enabled="True"
                                ParentControlID="code" LoadingText="Loding ..." PromptText="Select Type" 
                                ServiceMethod="GetType" ServicePath="~/WebService.asmx"
                                Category="type" UseContextKey="True">
                            </ajaxToolkit:CascadingDropDown>
                            &nbsp;&nbsp;
                            <asp:DropDownList ID="dem" runat="server" BackColor="White" Height="22px"
                                TabIndex="6" Width="170px">
                                <asp:ListItem></asp:ListItem>
                            </asp:DropDownList>
                            <ajaxToolkit:CascadingDropDown ID="dem_CascadingDropDown" 
                                runat="server" TargetControlID="dem" Enabled="True"
                                ParentControlID="type" LoadingText="Loding ..." PromptText="Select Dimension" 
                                ServiceMethod="GetDimension" ServicePath="~/WebService.asmx"
                                Category="dimension" UseContextKey="True">
                            </ajaxToolkit:CascadingDropDown>
                            &nbsp;&nbsp;
                            <asp:DropDownList ID="p" runat="server" BackColor="White" Height="22px" 
                            TabIndex="7" Width="130px" style="margin-top: 0px">
                                <asp:ListItem></asp:ListItem>
                            </asp:DropDownList>
                            <ajaxToolkit:CascadingDropDown ID="p_CascadingDropDown" 
                                runat="server" TargetControlID="p" Enabled="True"
                                ParentControlID="dem" LoadingText="Loding ..." PromptText="Select P" 
                                ServiceMethod="GetP" ServicePath="~/WebService.asmx"
                                Category="p" UseContextKey="True">
                            </ajaxToolkit:CascadingDropDown>
                            &nbsp;&nbsp;
                            <asp:DropDownList ID="minquant" runat="server" BackColor="White" Height="22px" 
                            TabIndex="7" Width="100px" style="margin-top: 0px"><asp:ListItem></asp:ListItem>
                            </asp:DropDownList>&nbsp;<ajaxToolkit:CascadingDropDown ID="minquant_CascadingDropDown" runat="server" 
                                TargetControlID="minquant"  Enabled="True"
                                ParentControlID="p" LoadingText="Loding ..." PromptText="Pcs/Carton" 
                                ServiceMethod="GetQuantity" ServicePath="~/WebService.asmx"
                                Category="quantity" UseContextKey="True">
                            </ajaxToolkit:CascadingDropDown>`
 [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
{
    public WebService()
    {
        //Uncomment the following line if using designed components
        //InitializeComponent();
    }
    [WebMethod]
    public CascadingDropDownNameValue[] GetCodes(string knownCategoryValues, string category)
    {
        OrdersDataContext db = new OrdersDataContext();
        IEnumerable<CascadingDropDownNameValue> vals = null;
        short targetID = 0;
        vals = (from c in db.codeTs
               select new CascadingDropDownNameValue
               {
                   name = c.code,
                   value = c.id.ToString(),
               }).OrderBy(t => t.name);
        return vals.ToArray<CascadingDropDownNameValue>();
    }
    [WebMethod]
    public CascadingDropDownNameValue[] GetType(string knownCategoryValues, string category)
    {
        OrdersDataContext db = new OrdersDataContext();
        IEnumerable<CascadingDropDownNameValue> vals = null;
        StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
        short code_Id;
        if (!kv.ContainsKey("code") || !short.TryParse(kv["code"], out code_Id))
        {
            return null;
        }
        vals = (from tp in db.typeTs
               where tp.codeId == code_Id
               select new CascadingDropDownNameValue
               {
                   name = tp.type,
                   value = tp.id.ToString(),
               }).OrderBy(t => t.name);
        return vals.ToArray<CascadingDropDownNameValue>();
    }
    [WebMethod]
    public CascadingDropDownNameValue[] GetDimension(string knownCategoryValues, string category)
    {
        OrdersDataContext db = new OrdersDataContext();
        IEnumerable<CascadingDropDownNameValue> vals = null;
        StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
        short type_Id;
        if (!kv.ContainsKey("type") || !short.TryParse(kv["type"], out type_Id))
        {
            return null;
        }
        vals = (from tp in db.dimTs
               where tp.typeId == type_Id
               select new CascadingDropDownNameValue
               {
                   name = tp.dimension,
                   value = tp.id.ToString(),
               }).OrderBy(t => t.name); 
        return vals.ToArray<CascadingDropDownNameValue>();
    }`

Web服务。当我通过firebug检查网络请求时,asmx方法根本没有被触发。url没有被正确解析。试着把完整的路径放到你网站的服务路径,像这样

ServicePath="http://smirdex.gr/OrderForm2.2/WebService.asmx"

解析url

ServicePath="<%# ResolveUrl('~/OrderForm2.2/WebServices.asmx') %>"

让我知道进展如何

更新。此错误显示在您的站点上在发布站点时,请确保将Ajax Control Toolkit dll复制到bin文件夹中。

并尝试解决这个链接

我也有同样的问题。在我安装了额外的角色服务后,它工作了,然后停止了。几个小时后,我发现在站点的Handler Mappings中,有一个用于*的脚本方法。Asmx版本号错误!查找公共令牌:B03F5F7F11D50A3A,如果看到2.0.0.0版本,则删除它。就是这样。

最新更新