简体   繁体   中英

While typing text in Textbox, I need to get search content using AJAX

如何使用带有jQuery的Ajax在Textbox上键入时显示搜索结果?

jquery autocomplete could be a good option for you.

It's not enough with jquery and you'll need to add the jqueryui library but you may be using more features from this library sooner than later.

Even i am beginner in ajax field yesterday i tried something...found on some website after googling i cud fetch this after ...

http://jqueryui.com/autocomplete/

just go through this if not i will give you my code...

I suggest this code of auto-complete.

http://www.devbridge.com/projects/autocomplete/jquery

It work with jQuery but is a small code that is not require so many extras javascript files to run, and also is highlight the words as you type.

it'll normally works-

    protected void TextBox7_TextChanged(object sender, EventArgs e)
{
    con.Open();

    SqlCommand cmd = con.CreateCommand();
    cmd.CommandType = CommandType.Text;
    cmd.CommandText = "select * from TableTest where Name like('" + TextBox7.Text + "%')";
    cmd.ExecuteNonQuery();
    DataTable dt = new DataTable();
    SqlDataAdapter da = new SqlDataAdapter(cmd);
    da.Fill(dt);
 // GridView1.DataSource = dt;

    con.Close();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM