.ASPX页面:
<%@ 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>无标题页</title>
<!-- Autosuggest includes: -->
<link rel="stylesheet" type="text/css" href="autosuggest.css"></link> <script type="text/javascript" src="autosuggest.js"></script> <!-- Autosuggest data: -->
<script type="text/javascript">
var custom_array = new Array();
<%
for(int InitialValue=0;InitialValue<2;InitialValue++)
{%>
custom_array.push("<%=proName[InitialValue]%>");
<%}%>
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<script type="text/javascript"> new autosuggest("TextBox1", custom_array); </script>
</div>
</form>
</body>
</html>
.CS代码:
public partial class _Default : System.Web.UI.Page
{
public string[] proName = new string[2]; //定义为公共数组
public int InitialValue = 0; //定义为公共,用于赋值循环
protected void Page_Load(object sender, EventArgs e)
{
for (int i = 0; i < 2; i++)
{
proName[InitialValue] = "a" + i.ToString();
InitialValue++;
}
}
}
我是参照http://www.codeproject.com/Articles/20174/Auto-suggest-Control将测试页面修改为C#,但只是实现了一维数组,我想实现二维数组赋值,结构['名称', '编号'],请问怎么实现,谢谢
var custom_array = [['audi', '1'], ['bentley', '2'], ['buick', '3'], ['chevrolet', '4'], ];
<%@ 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>无标题页</title>
<!-- Autosuggest includes: -->
<link rel="stylesheet" type="text/css" href="autosuggest.css"></link> <script type="text/javascript" src="autosuggest.js"></script> <!-- Autosuggest data: -->
<script type="text/javascript">
var custom_array = new Array();
<%
for(int InitialValue=0;InitialValue<2;InitialValue++)
{%>
custom_array.push("<%=proName[InitialValue]%>");
<%}%>
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<script type="text/javascript"> new autosuggest("TextBox1", custom_array); </script>
</div>
</form>
</body>
</html>
.CS代码:
public partial class _Default : System.Web.UI.Page
{
public string[] proName = new string[2]; //定义为公共数组
public int InitialValue = 0; //定义为公共,用于赋值循环
protected void Page_Load(object sender, EventArgs e)
{
for (int i = 0; i < 2; i++)
{
proName[InitialValue] = "a" + i.ToString();
InitialValue++;
}
}
}
我是参照http://www.codeproject.com/Articles/20174/Auto-suggest-Control将测试页面修改为C#,但只是实现了一维数组,我想实现二维数组赋值,结构['名称', '编号'],请问怎么实现,谢谢
var custom_array = [['audi', '1'], ['bentley', '2'], ['buick', '3'], ['chevrolet', '4'], ];
差不多,不过好像获取不到编号的值
<script type="text/javascript"> new autosuggest("TextBox1", custom_array, null, function(index, control) { alert("Selected key: \"" + control.keywords[index] + "\" with value: \"" + control.values[index] + "\""); }); </script>
这个不是二维数组是一个长度为2的一维数组啊,哥
不过这样是一个队列,非常好用,非常好玩
var treeCol = new Array();
for (var i = 0; i < 30; i++) {
//二维数组赋值
treeCol[i] = new Array();
for (var j = 0; j < count; j++) {
treeCol[i][j] = 0;
}