功能簡介:最近在做個憑證單子,裡面的一些編輯框是需要聯想功能的。
功能實現:在AJax功能的吸引下,我GOOGLE到了MS開發的
ASP.Net 2.0 AJax Extensions 1.0是基於.Net FRAMEWORK 2.0開發的,正合我意,下面利用
AutoCompleteExtender控件來實現我需要的功能
部分主要代碼如下:
Html界面代碼
<cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
cc1:ToolkitScriptManager>
<div>
<ASP:TextBox ID="TextBox1" runat="server">ASP:TextBox>
<cc1:AutoCompleteExtender ID="AutoCompleteExtender1" MinimumPrefixLength="1"
CompletionInterval="300"
EnableCaching="true"
CompletionSetCount="10"
BehaviorID="AutoCompleteEx" runat="server" ServiceMethod="GetCompletionList"
UseContextKey="True" TargetControlID="TextBox1">
<Animations>
<OnShow>
<Sequence>
<OpacityAction Opacity="0" />
<HideAction Visible="true" />
<ScriptAction Script="
// Cache the size and setup the initial size
var behavior = $find('AutoCompleteEx');
if (!behavior._height) {
var target = behavior.get_completionList();
behavior._height = target.offsetHeight - 2;
target.style.height = '0px';
}" />
<Parallel Duration=".1">
<FadeIn />
<Length PropertyKey="height" StartValue="0" EndValueScript="$find('AutoCompleteEx')._height" />
Parallel>
Sequence>
OnShow>
<OnHide>
<Parallel Duration=".1">
<FadeOut />
<Length PropertyKey="height" StartValueScript="$find('AutoCompleteEx')._height" EndValue="0" />
Parallel>
OnHide>Animations>
cc1:AutoCompleteExtender>
<script type="text/Javascript">
// Work around browser behavior of "auto-submitting" simple forms
var frm = document.getElementById("ASPnetForm");
if (frm) {
frm.onsubmit = function() { return false; };
}
script>
<input type="submit" style="display:none;" />
div>