【问题标题】:Ajax Cascading DropDownLists with web service don't work on server, the lists are empty带有 Web 服务的 Ajax 级联 DropDownLists 在服务器上不起作用,列表为空
【发布时间】:2013-05-04 20:49:31
【问题描述】:

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

【问题讨论】:

  • 如果有人想查看它,可以访问此页面smirdex.gr/OrderForm2.2/LogIn.aspx 并使用用户名 abins_Aimilios 并通过:5a>=nBiQR?MDe+ 提前谢谢!!!!
  • 我登录了。您网站的哪个页面有这些?
  • 在订单中,抱歉我忘记写...
  • 我建议让您的订单按钮在您的网站上更加显眼。我想提供帮助,浏览了您的产品,但仍然无法导航到订单表单以复制您的问题。我该怎么做。
  • 谢谢!!!您需要登录,然后,在正确的站点上有一个菜单,单击订单,您将看到 5 个空的下拉列表...再次感谢您的宝贵时间!

标签: asp.net ajax drop-down-menu web cascading


【解决方案1】:

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

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

或者解析网址

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

告诉我进展如何

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

然后尝试解决这个link

【讨论】:

  • 我尝试了两种方式,但没有结果...:(现在我有第一个"ServicePath="smirdex.gr/OrderForm2.2/WebService.asmx""
  • 您的网站有错误。 Sys.Application.add_init(function() { failed to load).Check your javascript on your page
  • 向我发送您的项目和数据库的压缩副本。 abidmix@gmail.com
【解决方案2】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-03
    相关资源
    最近更新 更多