Hi guys,
I've been trying to implement autocomplete on a form I'm creating and was successful with using a global variable as the source. Now i'm trying to use a hiddenfield as the source, but it does not seem to work. Firebug shows the error "414 Request-URI Too Long." Is there a way to set the autocomplete source to what I have in a hiddenfield?
//current code autocomplete implementation below
$(document).ready(function () {
var list = $("#<%= hf.ClientID %>").val();
var $tb = $("input[id$='id']");
alert(list); <--When checking what is inside of list, I see desired results
$($tb).autocomplete({
minLength: 6,
source: list <--However, when using as source we get no results
});
});
//markup
<asp:HiddenField ID="hf" runat="server" Value="" />
//codebehind
using (myconnectionstring)
{
SqlCommand cmd = new SqlCommand("SELECT * FROM..., myconnectionstring);
con.Open();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
while (sdr.Read())
{
if (string.IsNullOrEmpty(hf.Value.ToString()))
hf.Value += "\"" + sdr["id"].ToString() + "\"";
else
hf.Value += ", \"" + sdr["id"].ToString() + "\"";
}
}
con.Close();
}
thanks for your help!