Autocomplet extender control in ajax (asp.net)?

I am using autocomplete extender in my application but it is not working. This is my code: ServiceMethod=”GetVideoTitles” CompletionSetCount=”10″ ServicePath=”Myservices.asmx” ID=”AutoCompleteExtender1″ runat=”server”> This is the webservice method:public string[] GetVideoTitles(string prefixText) SqlConnection con = new SqlConnection(@”Data Source=SERVER5SQLserver2005;Initial Catalog=tpvnew;User ID=xx;Password=525″); con.Open(); SqlCommand cmd = new …

via Asp.Net Developed Tutorials » Search Results » ajax:

Autocomplet extender control in ajax (asp.net)?

I am using autocomplete extender in my application but it is not working. This is my code:

ServiceMethod=”GetVideoTitles” CompletionSetCount=”10″ ServicePath=”Myservices.asmx” ID=”AutoCompleteExtender1″ runat=”server”>

This is the webservice method:
public string[] GetVideoTitles(string prefixText)

SqlConnection con = new SqlConnection(@”Data Source=SERVER5SQLserver2005;Initial Catalog=tpvnew;User ID=xx;Password=525″);
con.Open();
SqlCommand cmd = new SqlCommand(“video_videotitles”, con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(“@prefixText”, SqlDbType.VarChar, 50);
cmd.Parameters[“@prefixText”].Value = prefixText;

SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
string[] items = new string[dt.Rows.Count];
int i = 0;
foreach (DataRow dr in dt.Rows)

items.SetValue(dr[“videotitle”].ToString(), i);
i++;

return items;
}
…………………………………………

Have you tried setting a breakpoint in your GetVideoTitles method, and verified that it returns any items?
…………………………………………

Try this trick
public string[] GetVideoTitles(string prefixText)
try

…Your code…

foreach (DataRow dr in dt.Rows)

items.SetValue(dr[“videotitle”].ToString(), i);
Debug.Write(dr[“videotitle”].ToString());
i++;

…Your code…
}
catch(Exception)

Debug.Assert(false);

}This way you first locate if somthing stop running on webservice method. Also use the DebugView from sysinternals to check live the data you get from Debug.write()
Debug View
Hope this 2 thinks help you locate the bug.
– Found this on asp.net forums– http://forums.asp.net/t/1123944.aspx
In most cases where the WebService method does not get calls becasue the WebMethod Signature does not match with the AutoComplete Extender signature. The Method signature needs to be:
string[] WSMethodName(string prefixText, int count)
You can have different method name but the parameter names and return type needs to be exact match even in case.
Reading this page http://www.vishwamohan.com/post/2007/05/07/AJAX-Error-Sys-is-undefined.aspx
and this page http://blogs.imeta.co.uk/TAxworthy/archive/2009/01/15/569.aspx Found that the sys problem can solve that way….
The most important line was:
allowDefinition=”MachineToApplication”

When compared to the application’s web.config, the last section was missing. When this line was amended, the javascript error was fixed, and the AJAX controls worked correctly again.
…………………………………………

Try to see if your web method GetVideoTitles() works or not. if it works, then check if you have set your .asmx web service path in the scriptmanager.





…………………………………………

you miss this
enter code here da.SelectCommand.Parameters.Add(“@prefixText”, SqlDbType.VarChar, 50).Value = **prefixText + “%”**;and in your query must use
enter code here like @prefixText

For more info: Autocomplet extender control in ajax (asp.net)?

Asp.Net Developed Tutorials » Search Results » ajax

Autocomplet extender control in ajax (asp.net)?

Share this post:

Related Posts

Leave a Comment