The front-end code is as follows:
Copy codeThe Code is as follows:
<% @ Page Language = "C #" AutoEventWireup = "true" CodeFile = "Default. aspx. cs" Inherits = "_ Default" %>
<! 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> Automatic completion of JQuery </title>
<Script src = "jquery. autocomplete/jquery-autocomplete/lib/jquery. js" type = "text/javascript"> </script>
<Script src = "jquery. autocomplete/jquery-autocomplete/jquery. autocomplete. min. js" type = "text/javascript"> </script>
<Link href = "jquery. autocomplete/jquery-autocomplete/jquery.autocomplete.css" rel = "stylesheet" type = "text/css"/>
<Script src = "jquery. autocomplete/jquery-autocomplete/demo/localdata. js" type = "text/javascript"> </script>
<Script type = "text/javascript">
$ (Document). ready (function (){
RaiseEvent ();
});
// The callback function after the request is completed
Function rServer (arg, context ){
Eval (arg );
$ ("# Sugest"). focus (). autocomplete (data );
}
// Initiate a Data Processing request to the server
Function raiseEvent (arg, context)
{
<% = ClientScript. GetCallbackEventReference (this, "arg", "rServer", "context") %>;
}
</Script>
</Head>
<Body>
<Form id = "form1" runat = "server">
<Div>
<Input type = "text" name = "text" id = "sugest" style = "width: 200px"/>
</Div>
</Form>
</Body>
</Html>
Then there is the background code. Of course, here we just simulate the data:
Copy codeThe Code is as follows:
Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Web;
Using System. Web. UI;
Using System. Web. UI. WebControls;
Using System. Text;
Public partial class _ Default: System. Web. UI. Page, ICallbackEventHandler
{
Protected void Page_Load (object sender, EventArgs e)
{
If (! IsPostBack)
{
}
}
Private StringBuilder GenStr ()
{
StringBuilder sbStr = new StringBuilder ();
SbStr. Append ("var data = ");
SbStr. Append ("[");
SbStr. Append ("\" Aback \",");
SbStr. Append ("\" back \",");
SbStr. Append ("\" cback \",");
SbStr. Append ("\" english \",");
SbStr. Append ("\" confidence \",");
SbStr. Append ("\" diligent \",");
SbStr. Append ("\" honor \",");
SbStr. Append ("\" delicious \"");
SbStr. Append ("];");
Return sbStr;
}
Public string GetCallbackResult ()
{
Return GenStr (). ToString ();
}
Public void RaiseCallbackEvent (string eventArgument)
{
}
}