2012年3月26日月曜日

restarting the autocomplete extender?

hi everyone,

I have an autocomplete textbox and detailsview control inside of update panel with partial rendering enabled. When I use the autocomplete control first the time and click on the search button, the detailsview control loads the data and displays it.

But when delete the textbox and start typing again, it no longer autocompletes. Does this work or is there something wrong with my code.

thanks,

gavin

Code Behind

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Lookup : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void ButtonLookup_Click(object sender, EventArgs e)
{
DataSet1TableAdapters.StaffTableAdapter TAStaff = new DataSet1TableAdapters.StaffTableAdapter();

DetailsView.DataSource = TAStaff.GetStaffInfoByName(SearchKey.Text);
DetailsView.DataBind();
DetailsView.Visible = true;
}
}

HTML Page

<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeFile="Lookup.aspx.cs" Inherits="Lookup" %
<!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 id="Head1" runat="server">
<atlas:ScriptManager runat="server" EnablePartialRendering="true" ID="scriptManager">
</atlas:ScriptManager>
<style type="text/css">
body { font: 11pt Trebuchet MS;
font-color: #000000;
padding-top: 72px;
text-align: center }

.text { font: 8pt Trebuchet MS }
</style>

</head>

<body>
<form id="Form1" action="" runat="server">

<atlas:UpdatePanel ID="Panel2" Mode="Always" runat="server">
<ContentTemplate
<div>
Search for
<asp:TextBox ID="SearchKey" runat="server"></asp:TextBox>
<asp:Button ID="ButtonLookup" runat="server" Text="Lookup" OnClick="ButtonLookup_Click" />

</div>
<hr style='width: 300px'/
<asp:DetailsView ID="DetailsView" runat="server" Height="196px" Width="323px">
</asp:DetailsView>
</ContentTemplate>
</atlas:UpdatePanel
</form>

<div id="completionList"></div>
<div>
<span id="Results">Here's some other text that shouldn't refresh.</span></div
<script type="text/javascript">
function DoSearch()
{
var SrchElem = document.getElementById("SearchKey");
Samples.AspNet.HelloWorldService.HelloWorld(SrchElem.value,
OnRequestComplete);
}

function OnRequestComplete(result)
{
var RsltElem = document.getElementById("Results");
RsltElem.innerHTML = result;
}

</script
<script type="text/xml-script">
<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
<components>
<textBox id="SearchKey">
<behaviors>
<autoComplete
completionList="completionList"
serviceURL="AutoCompleteService.asmx"
serviceMethod="GetWordList"
minimumPrefixLength="1"
completionSetCount="15"
completionInterval="500" />
</behaviors>
</textBox>
</components>
</page>
</script>
</body>
</htmlHi gfun,

The AutoCompleteExtender isn't part of the Toolkit, so you'll have better luck asking this question in theAJAX UI forum.

Thanks,
Ted

0 件のコメント:

コメントを投稿