1 [System.Web.Script.Services.ScriptService()] 2publicclass CarsService : System.Web.Services.WebService 3{ 4// Member variables 5privatestatic XmlDocument _document; 6privatestaticobject _lock =newobject(); 7 8// we make these public statics just so we can call them from externally for the 9// page method call 10publicstatic XmlDocument Document 11{ 12get 13{ 14lock (_lock) 15{ 16if (_document ==null) 17{ 18// Read XML data from disk 19 _document =new XmlDocument(); 20 _document.Load(HttpContext.Current.Server.MapPath("CarsService.xml")); 21 } 22 } 23return _document; 24 } 25 } 26 27publicstaticstring[] Hierarchy 28{ 29get{ returnnewstring[] { "make", "model" }; } 30 } 31 32/**//// 33/// Helper web service method 34/// 35///private storage format string 36///category of DropDownList to populate 37///list of content items 38 [WebMethod] 39public AjaxControlToolkit.CascadingDropDownNameValue[] GetDropDownContents(string knownCategoryValues, string category) 40{ 41// Get a dictionary of known category/value pairs 42 StringDictionary knownCategoryValuesDictionary = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues); 43 44// Perform a simple query against the data document 45return AjaxControlToolkit.CascadingDropDown.QuerySimpleCascadingDropDownDocument(Document, Hierarchy, knownCategoryValuesDictionary, category); 46 } 47 }