in

@Prog! - ASP.NET(C#) AJAX -

ASP.NET(C#) 2.0 & ASP.NET Ajax (ATLAS) のメモ書き

ASP.NET Ajax AutoCompleteExtender を使用する

最新の投稿は、投稿日時: 2006/11/07 3:01 投稿者: ASANO です。スレッドには 1 件の返答があります。
ページ 1 / 1 (2 アイテム)
投稿の並べ替え: 前へ 次へ
  • 2006/11/07 2:57

    ASP.NET Ajax AutoCompleteExtender を使用する

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default10.aspx.cs" Inherits="Default10" %>

    <%@ Register Assembly="Microsoft.Web.Preview" Namespace="Microsoft.Web.Preview.UI.Controls"
        TagPrefix="Preview" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>ASP.NET Ajax AutoCompleteExtender を使用する</title>
    </head>
    <body>
        <form id="form1" runat="server">
       
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
       
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            <asp:Panel ID="Panel1" runat="server">
            </asp:Panel>
           
            <Preview:AutoCompleteExtender ID="AutoCompleteExtender1"
                runat="server"
                MinimumPrefixLength="1"
                ServiceMethod="AjaxAutoCompleteWord"
                ServicePath="AutoCompleteExtender.asmx"
                TargetControlID="TextBox1"
                CompletionListElementID="Panel1" />
               
        </form>
    </body>
    </html>

  • 2006/11/07 3:01 回答元:

    Re: ASP.NET Ajax AutoCompleteExtender を使用する

    using System;
    using System.Web;
    using System.Collections;
    using System.Web.Services;
    using System.Web.Services.Protocols;

    using System.Collections.Generic;
    using Microsoft.Web.Script.Services;

    /// <summary>
    /// AutoCompleteExtender の概要の説明です
    /// </summary>
    [ScriptService]
    [WebService(Namespace = "http://momotchi.net/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class AutoCompleteExtender : System.Web.Services.WebService {

        public AutoCompleteExtender () { }

        [WebMethod]
        public string[] AjaxAutoCompleteWord(string prefixText)
        {
            List<string> list = new List<string>();
            list.Add("Red");
            list.Add("Blue");
            list.Add("Yellow");
            list.Add("White");
            list.Add("Black");

            List<string> find = list.FindAll(delegate(string s)
            {
                if (prefixText.Equals(s.Substring(0, prefixText.Length), StringComparison.CurrentCultureIgnoreCase))
                    return true;
                else
                    return false;
            });

            return find.ToArray() as string[];
        }
       
    }

ページ 1 / 1 (2 アイテム)