實(shí)現(xiàn)輸入框能填寫(xiě)能下拉選擇,填寫(xiě)時(shí)動(dòng)態(tài)提示
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Default2 :
System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
}
using (UsersDataContext con = new UsersDataContext())
{
string s = "" ;
int count = 0;
List ulist = con.Users.ToList();
for (int i = 0; i < ulist.Count; i++)
{
if (count > 0)
s += ",";
s += ulist[i].Nickname;
count++;
}
HiddenField1.Value = s; //將需要的信息放到隱藏控件中
}
}
}
后臺(tái)數(shù)據(jù)
<%@ Page Language="C#"
AutoEventWireup="true" CodeFile="Default2.aspx.cs"
Inherits="Default2" %>
用戶名:
="text/javascript">
var b = $("#HiddenField1").val();//取隱藏的值
var strs = new Array();//定義數(shù)組
strs = b.split(",");//將字符分割
var v = "";
for (var i = 0; i < strs.length;i++)
{
v += "";
}
$("#li").html(v);
//取值從TextBox中取
$("#TextBox1").change(function () {
var av = $("#TextBox1").val();
$("#Label1").html(av);
});
頁(yè)面展示
H??K??F