webservice.cs

来自「asp.net ajax的例子」· CS 代码 · 共 71 行

CS
71
字号
using System;
using System.Web;
using System.Collections.Generic;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml;
using System.Collections.Specialized;

/// <summary>
/// WebService 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
//用以调用Web Service方法签名
[System.Web.Script.Services.ScriptService]
public class WebService : System.Web.Services.WebService {

    public WebService () {}

    private static XmlDocument xmlDoc;
    private static object objectLock = new object();

    public static XmlDocument Document
    {
        get
        {
            lock (objectLock)
            {
                if (xmlDoc == null)
                {
                    xmlDoc = new XmlDocument();
                    xmlDoc.Load(HttpContext.Current.Server.MapPath("~/App_Data/XML.xml"));
                }
            }
            return xmlDoc;
        }
    }

    public static string[] Hierarchy
    {
        get
        {
            return new string[] { "province", "city" };
        }
    }
    [WebMethod]
    //下拉菜单提示
    //public string[] GetCompletionList(string prefixText, int count)
    //{
    //    Random random = new Random();
    //    List<string> items = new List<string>(count);
    //    for (int i = 0; i < count; i++)
    //    {
    //        char c1 = (char)random.Next(65,90);
    //        char c2 = (char)random.Next(97, 122);
    //        char c3 = (char)random.Next(48, 57);
    //        char c4 = (char)random.Next(33, 43);
    //        items.Add(prefixText + c1 + c2 + c3 + c4);
    //    }
    //    return items.ToArray();
    //}


    public AjaxControlToolkit.CascadingDropDownNameValue[] GetDropDownContents(string knownCategoryValues, string category)
    {
        StringDictionary knownCategoryValuesDictionary = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
        return AjaxControlToolkit.CascadingDropDown.QuerySimpleCascadingDropDownDocument(Document, Hierarchy, knownCategoryValuesDictionary, category);
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?