hungquang_itsyad-yahoo.com
-
6/8/2012 5:41:56 AM
[Mothod 500 error]
Hi, I'm trying to use CascadingDropDown to loading data from table "Provinces" and "Districts".
I create WebService.asmx in /CMSTemplate/Webproject and WebService.cs in App_Code.
Below some code for WebService.cs
using System; using System.Linq; using System.Web; using System.Collections; using System.Collections.Generic; using System; using System.Collections; using System.Linq; using System.Web; using System.Web.Services; using System.Web.Services.Protocols; using System.Xml.Linq; using AjaxControlToolkit; using System.Collections.Generic; using System.Data; using System.Collections.Specialized;
//using System.Web.Script.Services;
/// <summary> /// Summary description for Provinces /// </summary> /// //[ScriptService] [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.ScriptMethod] [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 string HelloWorld() { return "Hello World"; }
[WebMethod] public CascadingDropDownNameValue[] Provices(string knownCategoryValues, string category) { DataTable dt = new DataTable(); dt = _SqlHelper.ExecuteDataTable("select Province,NodeID from View_greenway_Provinces_joined order by NodeOrder");
List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>(); for (int x = 0; x < dtRows.Count; x++) { values.Add(new CascadingDropDownNameValue(dt.Rows[x]["Province"].ToString(), dt.Rows[x]["NodeID"].ToString())); } return values.ToArray(); }
Below some code in ASPX page
<asp:DropDownList runat="server" ID="ddlProvices" Width="200px"/> <ajaxToolkit:CascadingDropDown runat="server" ID="CascadingDropDown1" TargetControlID="ddlProvinces" Category="Provinces" PromptText="Please..." LoadingText="Loading..." ServicePath="WebService.asmx" ServiceMethod="Provices"></ajaxToolkit:CascadingDropDown>
The option result is [Method Error 500]
HOW DO I FIX IT?
Thank!
|