You must Sign In to post a response.
  • Category: ASP.NET

    Why not AutoCompleteExtender working in bootstrap into asp.net

    Hi,
    I am using ajax AutoCompleteExtender for fill farmer name. but is not working.

    <%@ Page Title="" Language="C#" MasterPageFile="~/OTSMaster.master" AutoEventWireup="true"
    CodeFile="MyTest.aspx.cs" Inherits="MyTest" %>

    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="cHead" runat="Server">
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta http-equiv="Page-Enter" content="Alpha(opacity=1.05)" />
    <meta http-equiv="Page-Exit" content="Alpha(opacity=1.05)" />
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" />
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="mBody" runat="Server">
    <asp:UpdatePanel ID="upFarmer" runat="server">
    <Triggers>
    <asp:PostBackTrigger ControlID="tbFarmerName" />
    </Triggers>
    <ContentTemplate>
    <div class="col-sm-4 form-group">
    <b>Farmer Name</b>
    <asp:TextBox ID="tbFarmerName" runat="server" AutoPostBack="true" class="form-control">
    </asp:TextBox>
    <asp:AutoCompleteExtender ID="aceFarmerName" runat="server" TargetControlID="tbFarmerName"
    MinimumPrefixLength="1" EnableCaching="true" Enabled="true" CompletionSetCount="1"
    CompletionInterval="100" ServiceMethod="GetFarmerName">
    </asp:AutoCompleteExtender>
    </div>
    </ContentTemplate>
    </asp:UpdatePanel>
    </asp:Content>

    Code in c#
    ----------
    [System.Web.Script.Services.ScriptMethod()]
    [WebMethod]
    public static List<string> GetFarmerName(string preFixText)
    {
    DataTable source;
    FarmerEntity farmerEntity;
    FarmerLogic farmerLogic;
    int incVal;

    try
    {
    farmerEntity = new FarmerEntity();

    farmerEntity.Name = preFixText;

    farmerLogic = new FarmerLogic();

    source = farmerLogic.SelectFarmerName(farmerEntity);

    List<string> farmerName = new List<string>();

    for (incVal = 0; incVal < source.Rows.Count; incVal++)
    {
    farmerName.Add(source.Rows[incVal]["NAME"].ToString());
    }

    return farmerName;
    }
    catch (Exception ex)
    {
    throw ex;
    }
    finally
    {
    source = null;
    farmerEntity = null;
    farmerLogic = null;
    }
    }
  • #767198
    hi,
    First have you tried debugging that webmethod? is there any exception you are getting? is it returning exact farmerName list from code behind?
    Second thing remove AutoPostBack="true" from your TextBox 'tbFarmerName' and remove PostBackTrigger for 'tbFarmerName' too and check once.

  • #767238
    Hi,

    Have you got any error while calling web method? Please elaborate your requirement with details rather than post your full code, just put a break point and check whether webmethod has been triggered while entering text into textbox control also remove AutoPostBack property for textbox control it is not required in your case.

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #767242
    Can you provide the error details? If you are getting any exception., give us the details of the error. If you are not getting any exception but not getting data fallowing are some of the tips.

    Check the values is population property? In you code you are trying to get the newly created instance. Are you how you are getting the data. Can you post that part of code?

    farmerLogic = new FarmerLogic();
    source = farmerLogic.SelectFarmerName(farmerEntity);

    By Nathan
    Direction is important than speed


  • Sign In to post your comments