I am working with the Ajax control kit to add an autocomplete to my search textbox. I cannot get it to work using a PageMethod or a webservice on my masterpage. I was able to create a new page not using a masterpage and it worked. Here is my code.
Edit- I found out Page-Method does not work in a masterpage. I am still having trouble calling the web service though. I add a service refrence to it then add this to the extender "ServicePath="NameWebService.asmx"" I still get nothing. I check to see if
the server side is getting hit and it is not.
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class NameSearch : System.Web.Services.WebService
{
[WebMethod]
public string[] GetSearchResult(string prefixText, int count)
{
List<Person> listPerson = Person.SearchForPerson(prefixText);
string[] arrayNames = listPerson.Select(n => n.FullName).Take(count).ToArray();
AbuseReport report = new AbuseReport();
report.AbuserPersonID = -1;
report.Message = prefixText;
report.ReportingPersonID = -1;
report.CreateAbuseReport();
return arrayNames;
}
} // End of Service
You mark up looks correct. You may place a break point to check if it goes to method in your werb service and debug your arrayNames, see if you get all correct string type.
axufuris
Member
2 Points
7 Posts
Ajax autocompleteextender not workin gon my masterpage
Feb 24, 2012 03:56 PM|LINK
I am working with the Ajax control kit to add an autocomplete to my search textbox. I cannot get it to work using a PageMethod or a webservice on my masterpage. I was able to create a new page not using a masterpage and it worked. Here is my code.
Edit- I found out Page-Method does not work in a masterpage. I am still having trouble calling the web service though. I add a service refrence to it then add this to the extender "ServicePath="NameWebService.asmx"" I still get nothing. I check to see if the server side is getting hit and it is not.
<asp:ScriptManager ID ="ScriptManager2" EnableCdn="true" LoadScriptsBeforeUI="false" runat="server" EnablePageMethods="true" /> <asp:Panel ID="pnlSearch" runat="server" DefaultButton="btnSearch"> <asp:TextBox ID="txtSearch" CssClass="textbox" placeholder="User Name/ Full Name" runat="server" Width="200px" AutoComplete="off" /> <asp:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" TargetControlID="txtSearch" ServiceMethod="GetSearchResult" MinimumPrefixLength="2" /> <asp:Button ID="btnSearch" runat="server" CssClass="buttonSubmit" Text="Search" onclick="btnSearch_Click" /> </asp:Panel>This is my page method
[System.Web.Services.WebMethod] public static string[] GetSearchResult(string prefixText, int count) { List<Person> listPerson = Person.SearchForPerson(prefixText); string[] arrayNames = listPerson.Select(n => n.FullName).Take(count).ToArray(); AbuseReport report = new AbuseReport(); report.AbuserPersonID = -1; report.Message = prefixText; report.ReportingPersonID = -1; report.CreateAbuseReport(); return arrayNames; }This is my webservice
[WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. [System.Web.Script.Services.ScriptService] public class NameSearch : System.Web.Services.WebService { [WebMethod] public string[] GetSearchResult(string prefixText, int count) { List<Person> listPerson = Person.SearchForPerson(prefixText); string[] arrayNames = listPerson.Select(n => n.FullName).Take(count).ToArray(); AbuseReport report = new AbuseReport(); report.AbuserPersonID = -1; report.Message = prefixText; report.ReportingPersonID = -1; report.CreateAbuseReport(); return arrayNames; } } // End of ServiceBU XI - MSFT
All-Star
22367 Points
2704 Posts
Microsoft
Re: Ajax autocompleteextender not workin gon my masterpage
Feb 28, 2012 03:14 AM|LINK
Hello
You mark up looks correct. You may place a break point to check if it goes to method in your werb service and debug your arrayNames, see if you get all correct string type.
If you have any feedback about my replies, please contact msdnmg@microsoft.com.
Microsoft One Code Framework
chetan.sarod...
All-Star
65729 Points
11133 Posts
Re: Ajax autocompleteextender not workin gon my masterpage
Feb 29, 2012 02:22 AM|LINK
Hi, Please refer this
http://forums.asp.net/p/1356612/2794715.aspx
http://forums.asp.net/p/1275227/2422860.aspx
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.