0

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!

2
Contributors
1
Reply
7
Views
4 Years
Discussion Span
Last Post by LastMitch
0

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?

@while(!success)

You are missing some lines from your javascript code?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.