在公司做的2个Web控件,给大家共享下
第一个是类似google的结果提示框
使用很简单,把控件拖到页面上后,设置下属性
ColumnTextIndex表示显示的文本的列号,ColumnValuendex表示Value值的列号,ShowHeader表示是否显示表头
再实现Search事件
后台实例代码如下:
protected object AjaxTextBox1_Search(object sender, HampWebControl.AjaxTextBox.SearchEventArgs e) { String connStr = @"server=PC-200902201516\SQLEXPRESS;database=IPSystem;uid=sa;pwd=123456"; String sql = "select id,name from person where name like '%"+e.Text.Trim()+"%'"; using (SqlConnection conn = new SqlConnection(connStr)) { conn.Open(); SqlCommand sd = new SqlCommand(sql, conn); SqlDataAdapter sa = new SqlDataAdapter(sd); DataTable dt = new DataTable(); sa.Fill(dt); return dt; } }protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { HampToolTip1.ControlToTip = Label1.ClientID; } }