asp.net - jQuery Autocomplete onselect redirect (info from database) -


I want to input an autocomplete search, and when a user selects an item, Is sent to the definitive page. I have a database that contains names and URLs. So far, I have been able to get names from the database, and do the work completely. The thing is, I do not know how to create a connection between the selection event for the specific URL of the name.

I am using asp.net:

My .ASHX file:

  public zero process measure (HTTP reference reference) {context .Response.ContentType = "Applications / JavaScript"; String cnString = "cnnstringlocation"; String sql = "SELECT Name FROM [Table] where name like '%' + @ term + '%'"; SQL Commands CMD = New SQL Commands (SQL, New SQL Connection (CNS String)); Cmd.CommandType = CommandType.Text; Cmd.Parameters.AddWithValue ("@word", context.Request.QueryString ["word"]); SqlDataAdapter da = New SqlDataAdapter (cmd); Datatable dt = new datatable (); Da.Fill (DT); String [] items = new string [dt.Rows.Count]; Int ctr = 0; Foreach (DataRow row in dt.Rows) {item [CTR] = (string) row ["name"]; CTR ++; } Context.Response.Write (New JavaScriptSerializer (.) Serialize (item)); }   

and autocomplete query (it is quite simple, I have made some efforts that revolve with the database and change the source, so I will have access to the URL, but Without any fate)

  $ ('# tag'). Autocomplete ({source: 'autocomplete.ashx'});   

I'm very new to jQuery, but I think that the name represnting string only in the source, but the URL for each name should not be too. I did not get the correct syntax for doing this anywhere. Edit: I think I can create another .ASHX file that will choose the selected fire and then give the required specific URL Is this the correct approach? Is there any easier way? Thanks for any light on that matter.

Use the selection function, and then after selecting here you can redirect the reference URL



Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -