gpt4 book ai didi

c# - 在 ASP.NET 4.5 的 AutoCompleteExtender 中添加滚动条

转载 作者:太空宇宙 更新时间:2023-11-03 13:05:31 28 4
gpt4 key购买 nike

现在我有一个关于在 ASP.NET 4.5 的 autoCompleteExtender 中添加滚动条的问题。我想开发带有自动完成系统添加滚动条的文本框。但是,如下代码,我无法让滚动条添加自动完成系统

我的代码如下

aspx&cs文件

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AutoCompletEextender.aspx.cs" Inherits="AutoCompleteTest6.AutoCompletEextender" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender
ID="TextBox1_AutoCompleteExtender"
runat="server"
CompletionInterval="50"
CompletionSetCount="40"
EnableCaching="False"
MinimumPrefixLength="0"
ServiceMethod="GetAutoCompTestListAAAA"
ServicePath="AutoCompList.asmx"
TargetControlID="TextBox1">
</ajaxToolkit:AutoCompleteExtender>
</form>
</body>
</html>



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace AutoCompleteTest6
{
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
public class AutoCompList : System.Web.Services.WebService
{

[WebMethod]
public string[] GetAutoCompTestListAAAA(string prefixText, int count)
{
string[] aAutoComp = new string[]{
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"};

string[] filterdList = aAutoComp.Where(str => (0 <= str.IndexOf(prefixText, StringComparison.CurrentCultureIgnoreCase))).ToArray();
return filterdList;
}
}
}

构建后,AutoComplete 不显示滚动条。请教我。

最佳答案

添加一个 div 来保存列表元素,并在 y 轴上滚动溢出将有助于自动完成扩展器。

请尝试对 aspx 页面进行以下更改:

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<div id="listPlacement" style="height:100px; overflow-y:scroll;" ></div>
<ajaxToolkit:AutoCompleteExtender
ID="TextBox1_AutoCompleteExtender"
runat="server"
CompletionInterval="50"
CompletionSetCount="40"
CompletionListElementID="listPlacement"
EnableCaching="False"
MinimumPrefixLength="0"
ServiceMethod="GetAutoCompTestListAAAA"
ServicePath="AutoCompList.asmx"
TargetControlID="TextBox1">
</ajaxToolkit:AutoCompleteExtender>
</form>
</body>
</html>

关于c# - 在 ASP.NET 4.5 的 AutoCompleteExtender 中添加滚动条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30909304/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com