aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AddShip.aspx.cs" Inherits="ShipAgency_AddShip"  %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>新增船舶规范</title>
  <link href="../css/register.css" rel="Stylesheet" type="text/css"/>
 <link href="../css/BgImage.css" rel="Stylesheet" type="text/css"/>

      <script type="text/javascript">
 
      onload= function foo() {
        //国籍
        var dataSource = [];
        dataSource= ShipAgency_AddShip.GetSearchItemsListCountry();
        var textBox = document.getElementById("tbxAddNationality");
        var configs = {
          instanceName: "auto",
          textbox: textBox,
          dataSource: dataSource.value
        }
        window.auto = new neverModules.modules.autocomplete(configs);
        
        //目的港
        var dataSourcePort = [];
        dataSourcePort = ShipAgency_AddShip.GetSearchItemsListPort();
        var textBox_tbxAddSHIPPORT = document.getElementById("tbxAddSHIPPORT");
        var configs_tbxAddSHIPPORT = {
          instanceName: "auto_tbxAddSHIPPORT",
          textbox: textBox_tbxAddSHIPPORT,
          dataSource: dataSourcePort.value
        }
        window.auto_tbxAddSHIPPORT = new neverModules.modules.autocomplete(configs_tbxAddSHIPPORT);

      }
 
    </script>
      <script type= "text/javascript" src="../JS/autocomplete_extras.js"></script>
   <link href="../css/autocomplete_custom_main.css" rel="Stylesheet" type="text/css"/>
   <link href="../css/autocomplete_custom.css" rel="Stylesheet" type="text/css"/>

</head>
<body>
    <form id="form1" runat="server">
    <div><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" id="__01">
    
    
    <tr valign="top" >
        <td colspan="0" style="height: 500px">            
          <div align="center">
            <TABLE width="100%" border=0 align="center" bordercolor="#000000">
              <TBODY>
                <TR>
                  <TD ><FIELDSET>
                    <LEGEND accessKey=F align=left><span class="style3">船舶规范</span></LEGEND>
                      <table align="center" border="0" cellpadding="0" cellspacing="2" width="95%">
                          <tbody>
                              <tr>
                                  <td nowrap="nowrap" style="width: 79px; height: 18px;" align="right">
                                      <div align="right">
                                          注册港:</div>
                                  </td>
                                  <td style="text-align: left; height: 18px; width: 160px;"><input name="tbxAddSHIPPORT" type="text" id="tbxAddSHIPPORT"  onkeyup="auto_tbxAddSHIPPORT.handlerEvent(event);" runat="server" style="width: 308px"></td>
                                  <td style="height: 17px; width: 82px;" align="right">
                                      <div align="right">
                                           </div>
                                  </td>
                                  <td style="width: 164px; text-align: left; height: 18px;">
                                      </td>
                                  <td style="height: 18px; width: 67px;" align="right">
                                      <span style="color: #ff0000">*</span>国籍:</td>
                                  <td style="height: 18px">
                                   <input name="tbxAddNationality" type="text" id="tbxAddNationality"  onkeyup="auto.handlerEvent(event);" runat="server" style="width: 126px"></td>
                              </tr>
                          </tbody>
                      </table>
                    <br>
                      </FIELDSET></TD>
                </TR>
              </TBODY>
            </TABLE>
         </div></td>
  </tr>
</table>    </div>
    </form>
</body>
</html>
cs:
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;

using AjaxPro;
using System.Data.OracleClient;

public partial class ShipAgency_AddShip : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        // 在此处放置用户代码以初始化页面
        Utility.RegisterTypeForAjax(typeof(ShipAgency_AddShip));
        if (!IsPostBack)
        {

        }
    }


    [AjaxMethod()]
    public ArrayList GetSearchItemsListCountry(string query)
    {
        ArrayList items = new ArrayList();

        string myConnectionString = LTP.Common.DEncrypt.DESEncrypt.Decrypt(LTP.Common.ConfigHelper.GetConfigString("ConnectionString"));
        //"Data Source=JOINTWIN;Persist Security Info=True;User ID=penavico;Password=JointWin2007;Unicode=True";
        string mySelectQuery =
            string.Format(
            "select code,cn from country where code like '{0}%' and cn is not null",
            query);
        OracleConnection myConnection = new OracleConnection(myConnectionString);
        OracleCommand myCommand = new OracleCommand(mySelectQuery, myConnection);
        myConnection.Open();
        OracleDataReader myReader =
            myCommand.ExecuteReader(CommandBehavior.CloseConnection);
        while (myReader.Read())
        {
            items.Add(myReader.GetString(0) + "|" + myReader.GetString(1));
        }
        myReader.Close();

        return items;
    }

    [AjaxMethod()]
    public string[] GetSearchItemsListPort(string query)
    {
        ArrayList items = new ArrayList();

        string myConnectionString = LTP.Common.DEncrypt.DESEncrypt.Decrypt(LTP.Common.ConfigHelper.GetConfigString("ConnectionString"));
        string mySelectQuery =
            string.Format(
            "select en,cn from port where en like '{0}%' and cn is not null",
            query);
        OracleConnection myConnection = new OracleConnection(myConnectionString);
        OracleCommand myCommand = new OracleCommand(mySelectQuery, myConnection);
        myConnection.Open();
        OracleDataReader myReader =
            myCommand.ExecuteReader(CommandBehavior.CloseConnection);
        while (myReader.Read())
        {
            items.Add(myReader.GetString(0) + "|" + myReader.GetString(1));
        }
        myReader.Close();

        //String[] returnList = (String[])items.ToArray(new String[items.Count]);

        // String[] strList = new String[items.Count];
        // String[] returnList = (String[])items.ToArray(strList);

        // string[] returnList = (string[])items.ToArray(new string[items.Count]);
        string[] returnList = new string[items.Count];
        for (int i = 0; i < items.Count; i++)
        {
            returnList[i] = items[i].ToString();
        }

        return returnList;
    }

}
下载: /Files/ipusr/DownText.rar
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AddShip.aspx.cs" Inherits="ShipAgency_AddShip"  %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>新增船舶规范</title>
  <link href="../css/register.css" rel="Stylesheet" type="text/css"/>
 <link href="../css/BgImage.css" rel="Stylesheet" type="text/css"/>
      <script type="text/javascript">
 
      onload= function foo() {
        //国籍
        var dataSource = [];
        dataSource= ShipAgency_AddShip.GetSearchItemsListCountry();
        var textBox = document.getElementById("tbxAddNationality");
        var configs = {
          instanceName: "auto",
          textbox: textBox,
          dataSource: dataSource.value
        }
        window.auto = new neverModules.modules.autocomplete(configs);
        
        //目的港
        var dataSourcePort = [];
        dataSourcePort = ShipAgency_AddShip.GetSearchItemsListPort();
        var textBox_tbxAddSHIPPORT = document.getElementById("tbxAddSHIPPORT");
        var configs_tbxAddSHIPPORT = {
          instanceName: "auto_tbxAddSHIPPORT",
          textbox: textBox_tbxAddSHIPPORT,
          dataSource: dataSourcePort.value
        }
        window.auto_tbxAddSHIPPORT = new neverModules.modules.autocomplete(configs_tbxAddSHIPPORT);
      }
 
    </script>
      <script type= "text/javascript" src="../JS/autocomplete_extras.js"></script>
   <link href="../css/autocomplete_custom_main.css" rel="Stylesheet" type="text/css"/>
   <link href="../css/autocomplete_custom.css" rel="Stylesheet" type="text/css"/>
</head>
<body>
    <form id="form1" runat="server">
    <div><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" id="__01">
    
    
    <tr valign="top" >
        <td colspan="0" style="height: 500px">            
          <div align="center">
            <TABLE width="100%" border=0 align="center" bordercolor="#000000">
              <TBODY>
                <TR>
                  <TD ><FIELDSET>
                    <LEGEND accessKey=F align=left><span class="style3">船舶规范</span></LEGEND>
                      <table align="center" border="0" cellpadding="0" cellspacing="2" width="95%">
                          <tbody>
                              <tr>
                                  <td nowrap="nowrap" style="width: 79px; height: 18px;" align="right">
                                      <div align="right">
                                          注册港:</div>
                                  </td>
                                  <td style="text-align: left; height: 18px; width: 160px;"><input name="tbxAddSHIPPORT" type="text" id="tbxAddSHIPPORT"  onkeyup="auto_tbxAddSHIPPORT.handlerEvent(event);" runat="server" style="width: 308px"></td>
                                  <td style="height: 17px; width: 82px;" align="right">
                                      <div align="right">
                                           </div>
                                  </td>
                                  <td style="width: 164px; text-align: left; height: 18px;">
                                      </td>
                                  <td style="height: 18px; width: 67px;" align="right">
                                      <span style="color: #ff0000">*</span>国籍:</td>
                                  <td style="height: 18px">
                                   <input name="tbxAddNationality" type="text" id="tbxAddNationality"  onkeyup="auto.handlerEvent(event);" runat="server" style="width: 126px"></td>
                              </tr>
                          </tbody>
                      </table>
                    <br>
                      </FIELDSET></TD>
                </TR>
              </TBODY>
            </TABLE>
         </div></td>
  </tr>
</table>    </div>
    </form>
</body>
</html>
cs:
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;
using AjaxPro;
using System.Data.OracleClient;
public partial class ShipAgency_AddShip : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        // 在此处放置用户代码以初始化页面
        Utility.RegisterTypeForAjax(typeof(ShipAgency_AddShip));
        if (!IsPostBack)
        {
        }
    }

    [AjaxMethod()]
    public ArrayList GetSearchItemsListCountry(string query)
    {
        ArrayList items = new ArrayList();
        string myConnectionString = LTP.Common.DEncrypt.DESEncrypt.Decrypt(LTP.Common.ConfigHelper.GetConfigString("ConnectionString"));
        //"Data Source=JOINTWIN;Persist Security Info=True;User ID=penavico;Password=JointWin2007;Unicode=True";
        string mySelectQuery =
            string.Format(
            "select code,cn from country where code like '{0}%' and cn is not null",
            query);
        OracleConnection myConnection = new OracleConnection(myConnectionString);
        OracleCommand myCommand = new OracleCommand(mySelectQuery, myConnection);
        myConnection.Open();
        OracleDataReader myReader =
            myCommand.ExecuteReader(CommandBehavior.CloseConnection);
        while (myReader.Read())
        {
            items.Add(myReader.GetString(0) + "|" + myReader.GetString(1));
        }
        myReader.Close();
        return items;
    }
    [AjaxMethod()]
    public string[] GetSearchItemsListPort(string query)
    {
        ArrayList items = new ArrayList();
        string myConnectionString = LTP.Common.DEncrypt.DESEncrypt.Decrypt(LTP.Common.ConfigHelper.GetConfigString("ConnectionString"));
        string mySelectQuery =
            string.Format(
            "select en,cn from port where en like '{0}%' and cn is not null",
            query);
        OracleConnection myConnection = new OracleConnection(myConnectionString);
        OracleCommand myCommand = new OracleCommand(mySelectQuery, myConnection);
        myConnection.Open();
        OracleDataReader myReader =
            myCommand.ExecuteReader(CommandBehavior.CloseConnection);
        while (myReader.Read())
        {
            items.Add(myReader.GetString(0) + "|" + myReader.GetString(1));
        }
        myReader.Close();
        //String[] returnList = (String[])items.ToArray(new String[items.Count]);
        // String[] strList = new String[items.Count];
        // String[] returnList = (String[])items.ToArray(strList);
        // string[] returnList = (string[])items.ToArray(new string[items.Count]);
        string[] returnList = new string[items.Count];
        for (int i = 0; i < items.Count; i++)
        {
            returnList[i] = items[i].ToString();
        }
        return returnList;
    }
}
                    
                


      onload
                
            
        
浙公网安备 33010602011771号