below is my html file :
HTML Code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="AutoComplete.aspx.vb" Inherits="AutoComplete" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>AutoComplete Example</title>
<style type="text/css">
/*AutoComplete flyout */
.completionList {
border: solid 1px #444444;
margin: 0px;
padding: 2px;
height: 200px;
overflow: auto;
background-color: #FFFFFF;
}
.listItem {
color: #1C1C1C;
}
.itemHighlighted {
background-color: #ffc0c0;
}
</style>
<script type="text/javascript">
function onDataShown(sender, args) {
sender._popupBehavior._element.style.zIndex = 1000001;
sender._popupBehavior._element.style.left = "54px"; //set positions according to your requirement.
sender._popupBehavior._element.style.top = "50px"; //set top position according to your requirement.
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div class="col-md-3">
<div class="form-group fadeInUp position-relative">
<asp:Label ID="Label3" runat="server" Text="Search By Company Name" class="control-label" Font-Bold="True"></asp:Label>
<asp:TextBox ID="txtParty" runat="server" MaxLength="50" class="form-control" AutoPostBack="true"
Placeholder="Enter Company Name Here"></asp:TextBox>
<asp:AutoCompleteExtender ID="AutoCompleteExtenderParty" runat="server" TargetControlID="txtParty"
MinimumPrefixLength="1"
EnableCaching="true" CompletionSetCount="10" CompletionInterval="1000"
ServiceMethod="GetParty" CompletionListCssClass="completionList"
CompletionListHighlightedItemCssClass="itemHighlighted"
CompletionListItemCssClass="listItem" OnClientShown="onDataShown">
</asp:AutoCompleteExtender>
</div>
</div>
</form>
</body>
</html>
below is my Code :
Code:
Imports System.Web.Services
Imports System.Collections.Generic
Public Class AutoComplete
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
#Region "WebServices"
<System.Web.Script.Services.ScriptMethod()>
<System.Web.Services.WebMethod()>
Public Shared Function GetParty(prefixText As String) As List(Of String)
Dim ListOfCompanies As New List(Of String)()
' Sample data for demonstration
For i As Integer = 1 To 10
ListOfCompanies.Add("Company No. " & i.ToString())
Next
' Uncomment and use the following code to fetch data from the database
'Dim dt As New DataTable()
'Dim constr As String = ConfigurationManager.ConnectionStrings("SqlConnectionString").ToString()
'Using con As New SqlConnection(constr)
' Dim mWCmd As String = "SELECT CompanyName + ' | ' + Code as DName From SellerMaster WHERE CompanyName LIKE '%' + @mName + '%' ORDER BY CompanyName"
' Using cmd As New SqlCommand(mWCmd, con)
' cmd.Parameters.AddWithValue("@mName", prefixText)
' Dim adp As New SqlDataAdapter(cmd)
' adp.Fill(dt)
' End Using
'End Using
' For demonstration, we are returning the sample data
Return ListOfCompanies.Where(Function(c) c.StartsWith(prefixText, StringComparison.OrdinalIgnoreCase)).ToList()
End Function
#End Region
End Class
what is happening is that the autocomplete list is returning some weird html data. attached is the image of the data being returned.
i just cant understand what is happening. i am using VS2022
the same code is working fine in my VS2010
pls. help me out
thanks in advance