user983854
user983854

Reputation: 51

Textbox KeyPress event

I want to write following code in textbox key press event.

{

    Loc = Server.MapPath("App_Data\\State.mdb");
    string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Loc + ";";
    DataSet ds = new DataSet();
    OleDbConnection conn = new OleDbConnection(connectionString);
    conn.Open();
    OleDbCommand cmd = new OleDbCommand();
    cmd.Connection = conn;
    query = "Select * from MyCity";
    OleDbDataAdapter adp = new OleDbDataAdapter(query, conn);
    adp.Fill(ds);
    Repeater1.DataSource = ds;
    Repeater1.DataBind();
    conn.Close();

}

I have google 100 times and find many code regarding generating textbox key press event and they all do good but iam unable to associate the above code with textbox keypress event.Also the above code is written in .aspx.cs* file.

If any one can write the above code in .aspx file, that will also be a great help.

Any help is a great help....Many thanks.....

Upvotes: 0

Views: 1216

Answers (1)

agarcian
agarcian

Reputation: 3965

You need to use different technologies:

  • ASP.NET for the database call on the server side.
  • Expose this function as an API call. Basically you return json or XML results.
  • On the client, use Javascript (ideally JQuery) to wire up an AJAX event.

Please read this question in SO: how to write immediately search (c#)

Upvotes: 1

Related Questions