⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 webservice.cs

📁 asp.net ajax的例子
💻 CS
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -