Ajax Cascadedropdownlist不起作用 [英] Ajax Cascadedropdownlist is not working

查看:97
本文介绍了Ajax Cascadedropdownlist不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

我试图创建Ajax Cascadedropdownlist.为此,我创建了Web服务,其中包含2种方法,这些方法用于绑定aspx页面的下拉列表中的数据.

当我测试服务时,我会得到值列表列表.但是在aspx页面中,下拉列表显示

[方法错误12030]


以下代码:

在webservice.cs类中

 [WebMethod]
   [System.Web.Script.Services.ScriptMethod]
   公共 CascadingDropDownNameValue [] GetMakes(
     字符串 knownCategoryValues,
     字符串类别)
   {
     
       列表< CascadingDropDownNameValue>值=
         列表< CascadingDropDownNameValue>();
        for ( int  i =  1 ; i <  =  12 ; i ++)
       {
           字符串 make =(i.ToString());
            int  makeId =( int )i;
           values.Add( CascadingDropDownNameValue(
             make,makeId.ToString()));
       }
       返回值.ToArray();
   } 



在aspx页面中:

< ajaxToolkit:CascadingDropDown
ID = " 
runat = " 
TargetControlID = " 
Category = " 
PromptText = " 
ServicePath = " 
ServiceMethod = " /> 





谢谢
Sheik

解决方案

检查您的代码

在Web Service中的类定义之前添加[System.Web.Script.Services.ScriptService()].

因为Web服务是使用ASP.NET AJAX从Java脚本中调用的,所以必须使用System.Web.Script.Services.ScriptService装饰修饰包围的类,以使其起作用.


Dear All,

I tried to create the Ajax Cascadedropdownlist. For that i created the Web service which contains 2 methods used to bind the data in the dropdownlist in my aspx page.

When I test the serveice, I''m getting the list of values list. But in the aspx page, the dropdownlist shows

[Method Error 12030]


Code Below :

In webservice.cs class

[WebMethod]
   [System.Web.Script.Services.ScriptMethod]
   public CascadingDropDownNameValue[]  GetMakes(
     string knownCategoryValues,
     string category)
   {
     
       List<CascadingDropDownNameValue> values =
         new List<CascadingDropDownNameValue>();
       for (int i = 1; i <= 12; i++ )
       {
           string make = (i.ToString() ) ;
           int makeId = (int) i ;
           values.Add(new CascadingDropDownNameValue(
             make, makeId.ToString()));
       }
       return values.ToArray()  ;
   }



In aspx page :

<ajaxToolkit:CascadingDropDown
ID="CascadingDropDown1"
runat="server"
TargetControlID="ddlMake"
Category="Make"
PromptText="Select a manufacturer"
ServicePath="CarsService.asmx"
ServiceMethod="GetCarMakes" />





Thanks
Sheik

解决方案

Check your code

Add [System.Web.Script.Services.ScriptService()] before Class defination in Web Service.

Because the webservice is being called from java script, using ASP.NET AJAX, the enclosing class has to be decorated with the System.Web.Script.Services.ScriptService attibute to make it work.


这篇关于Ajax Cascadedropdownlist不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆