c# - AutoComplete functionality not firing -
i have project using asp.net 4.5 , c#. have textbox server control tied asp autocompleteextender. problem seems either not connection database there bug somewhere in code. not using web service simple aspx , aspx.cs code behind. haven't been able debug pinpoint actual problem yet because getting
uncaught exception thrown method called through reflection
and in process of figuring out causing problem.
here textbox control:
<div class="col-md-10"> <asp:textbox id="txtcontactssearch" runat="server"></asp:textbox> <cc1:autocompleteextender servicemethod="searchcustomers" minimumprefixlength="2" completioninterval="100" enablecaching="false" completionsetcount="10" targetcontrolid="txtcontactssearch" id="autocompleteextender1" runat="server" firstrowselected="false"> </cc1:autocompleteextender> <asp:requiredfieldvalidator runat="server" controltovalidate="studentid" cssclass="text-danger" display="dynamic" errormessage="the student id field required." /> </div>
and have ajax directive on declared on aspx page aswell:
<%@ register assembly="ajaxcontroltoolkit" namespace="ajaxcontroltoolkit" tagprefix="cc1" %>
and code behind implements functionality autocomplete:
using system; using system.collections.generic; using system.linq; using system.web; using system.data; using system.configuration; using system.data.sqlclient; using system.web.ui; using system.web.ui.webcontrols; public partial class searchstudent : system.web.ui.page { protected void page_load(object sender, eventargs e) { } [system.web.script.services.scriptmethod()] [system.web.services.webmethod] public static list<string> searchstudents(string prefixtext, int count) { using (sqlconnection conn = new sqlconnection()) { conn.connectionstring = configurationmanager .connectionstrings["defaultconnection"].connectionstring; using (sqlcommand cmd = new sqlcommand()) { cmd.commandtext = "select fname student_registration_form " + "fname @searchtext + '%'"; cmd.parameters.addwithvalue("@searchtext", prefixtext); cmd.connection = conn; conn.open(); list<string> students = new list<string>(); using (sqldatareader sdr = cmd.executereader()) { while (sdr.read()) { students.add(sdr["fname"].tostring()); } } conn.close(); return students; } } } }
the issue caught attention is: calling wrong method in autocomplete extender
<cc1:autocompleteextender servicemethod="searchcustomers" public static list<string> searchstudents(string prefixtext, int count) {
here can see have passed searchcustomers servicemehtod in page using searchstudents.
recently have tried twitter's typeahead autocomplete plugin easy , fast compare autocomplete extender. have might : textbox autocomplete using twitter typeahead in asp .net
Comments
Post a Comment