2

我需要有关 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>();
    }`
4

2 回答 2

0

我有同样的问题。在我安装其他角色服务后,Tt 工作然后停止。然后我摸索了几个小时,发现在站点的 Handler Mappings 中,*.asmx 的一个脚本方法的版本号错误!查找公共令牌:B03F5F7F11D50A3A,如果您看到版本 2.0.0.0,则将其删除。而已。

于 2014-02-28T15:09:30.733 回答
0

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

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

或者解析url

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

让我知道事情的后续

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

并在此链接上尝试解决方案

于 2013-05-10T10:07:40.633 回答