Click here to Skip to main content
15,890,361 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I have created function for get firstname from database and try to use that method into autotextextender for textbox but this is not working.
please help me how to resolve this?
Methos:

XML
[System.Web.Script.Services.ScriptMethod()]
       [System.Web.Services.WebMethod]
       public static List<string> GetEmpName(string prefixText)
       {

            Entities objEntities = new Entities();

            List<string> empName = new List<string>();
            string ename = "";
            var objList = (from i in objEntities.HCM_EMPLOYEE_DETAILS
                           where i.FIRST_NAME.Contains(prefixText)
                         select i).ToList();
            foreach (var i in objList)
            {
                ename = i.FIRST_NAME;
                empName.Add(ename);
            }


           return empName;
       }


Source:
XML
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="EmployeeForm.aspx.cs" Inherits="AutoTextboxUserControl.EmployeeForm" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods = "true"> </asp:ScriptManager>



Enter a Employee Name
<asp:TextBox ID="txtProductList" runat="server"></asp:TextBox>
<cc1:AutoCompleteExtender ServiceMethod="GetEmpName"
    MinimumPrefixLength="1"
    CompletionInterval="0" EnableCaching="false" CompletionSetCount="10"
    TargetControlID="txtProductList"
    ID="autoCompleteExtender1" runat="server" FirstRowSelected = "false" UseContextKey="True">
</cc1:AutoCompleteExtender>
    </div>
    </form>
</body>
</html>
Posted
Comments
walterhevedeich 15-Jan-14 2:54am    
Any error you have encountered? Did objList get populated by your LINQ statement?

1 solution

Try using this

C#
[System.Web.Services.WebMethod]
public static List<string> GetEmpName(string prefixText, int count)


instead of

C#
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static List<string> GetEmpName(string prefixText)
 
Share this answer
 

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