Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone,
I am struck with a unique problem. I have 1 usercontrol where I am this auto suggest extender. I am using this control on all the pages where ever I need autosuggest testbox but on 1 page its not working. I have registered the control on the page still its not working, can someone suggest me something?

XML
I am just calling the control on the page where i need this auto suggest textbox like this :
<uc1:ctrlFetchemps ID="ctrlFetchemps1" runat="server" />
I have registered it on the page like this :
  <%@ Register Src="~/WebUserControls/Common/ctrlFetchemps .ascx" TagName="ctrlFetchemps " TagPrefix="uc1" %>
Posted
Updated 11-Sep-13 1:31am
v2
Comments
Salman622 11-Sep-13 7:19am    
check out the sql query in your function
praveen sethiya 11-Sep-13 7:23am    
Thanks for the reply but I think I am just calling the control on the page, if its sql query who is at fault then this should have not worked from anywhere but this autosuggest is working fine from other pages. Please correct me if am wrong somewhere. Never used this auto suggest extender.
ZurdoDev 11-Sep-13 7:22am    
You'll need to post relevant code and what is different about the one page?
praveen sethiya 11-Sep-13 7:31am    
I am just calling the control on the page where i need this auto suggest textbox like this :
<uc1:ctrlFetchemps ID="ctrlFetchemps1" runat="server" />
I have registered it on the page like this :
<%@ Register Src="~/UserCtls/Common/ctrlFetchemps .ascx" TagName="ctrlFetchemps " TagPrefix="uc1" %>
ZurdoDev 11-Sep-13 8:01am    
Yes, but something about the page is different otherwise it would work too.

Thanks guys for replying though I have solved it myself. There was a javascript missing for the same. Thanks once again.
 
Share this answer
 
try this in your aspx page


XML
<asp:TextBox ID="Item_Name" runat="server" Width="200px"
            ontextchanged="Item_Name_TextChanged" AutoPostBack="True" TabIndex="2"></asp:TextBox>
        <asp:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" CompletionInterval="500" MinimumPrefixLength="1" ServiceMethod="Getdata"
                        TargetControlID="Item_Name" UseContextKey="True">
        </asp:AutoCompleteExtender>






and in .cs do as below

C#
[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
        public static string[] Getdata(string prefixText, int count, string contextKey)
        {
            SqlConnection con1 = new SqlConnection(Connection.getConnectionString());
            con1.Open();

            DataTable dt = new DataTable();
            SqlCommand cmd = new SqlCommand();
            SqlDataAdapter adap = new SqlDataAdapter("Your sql query for suggesstion, con1);
            adap.Fill(dt);

            string[] main = new string[0];
            int j = dt.Rows.Count; //ds.Tables["Ledger_Master"].Rows.Count;

            for (int i = 0; i < j; i++)
            {
                //if (ds.Tables[0].Rows[i].ItemArray[0].ToString().ToLower().StartsWith(prefixText.ToLower()))
                if (dt.Rows[i].ItemArray[0].ToString().ToLower().Contains(prefixText.ToLower()))
                {
                    Array.Resize(ref main, main.Length + 1);
                    //main[main.Length - 1] = ds.Tables[0].Rows[i].ItemArray[0].ToString();
                    main[main.Length - 1] = dt.Rows[i].ItemArray[0].ToString();
                    if (main.Length == 15)
                        break;
                }
            } con1.Close();
            Array.Sort(main);
            return main;
        }
 
Share this answer
 
v2
Comments
[no name] 11-Sep-13 8:58am    
I don't think this is not what OP is looking for..
praveen sethiya 11-Sep-13 9:04am    
Thanks for the code but in this code :
Item_Name_TextChanged is missing.
Also I tried to paas hard coded parameters to GetData but still its not working, page gets refreshed, dont know why.
Salman622 13-Sep-13 3:15am    
GETDATA is for auto complete and its working

and item_name_text_Change is for some other purpose that's why is have not put that code the requirement for auto complete on typing in text box is all depend on service method getdata

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900