Hi Everyone,

I have a doubt in Ajax Autocomplete Extender, im learning ASP.net with C# for 3 days and im unable to understand. i tried some code which is in forums but when i try to connect to my database it fails to retrive data from database i dont know what is happening there also. please someone with genius out there help me please. im using visual studio 2008 asp.net 3.5. Each and everyword from u people are important for me so please reply me as soon as possible. this is the first time im posting in forum if did any mistake or u unable to understand my question please forgive me.. Thanks and Sorry in advance


Sona

What is your doubt and what you are unable to understand?? would you elaborate on this...

hi yousuf,
Thanks a lot for replying me, coming to my doubt in visual studio 2008 i opened a default page and i placed a textbox, script manager and ajax autocomplete extender then i created webservice.asmx and xml file where i have my data to be displayed in autocompleteextender, im sorry that my code is messed up and im unable to produce it at present. can u please give me any sample code using xml file that will be great help for me i ll collect my code and forward it later please. waiting for ur kind reply.

thanks once again,
sona

hi yousuf,
Thanks a lot for replying me, coming to my doubt in visual studio 2008 i opened a default page and i placed a textbox, script manager and ajax autocomplete extender then i created webservice.asmx and xml file where i have my data to be displayed in autocompleteextender, im sorry that my code is messed up and im unable to produce it at present. can u please give me any sample code using xml file that will be great help for me i ll collect my code and forward it later please. waiting for ur kind reply.

thanks once again,
sona

Hi Sona

Here you go...

Aspx

<asp:TextBox ID="txtProductCode" runat="server"></asp:TextBox>
                    <cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" ServicePath="AutoCompleteProductCode.asmx"
                        ServiceMethod="GetProductDescBynumber" MinimumPrefixLength="1" CompletionSetCount="10"
                        EnableCaching="false" TargetControlID="txtProductCode" OnClientItemSelected="PartNoSelected">
                    </cc1:AutoCompleteExtender>

Code behind

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Not IsPostBack Then

            Page.RegisterStartupScript("script1", getScript())
         End If

    End Sub
Private Function getScript() As String

        myStr.Append("<script language=Javascript>")
        myStr.Append("function PartNoSelected( source, eventArgs ) ")
        myStr.Append("{")
        'myStr.Append("var txtProductDesc = window.document.getElementById('<%=txtProductDesc.ClientID %>');")
        myStr.Append("var txtProductDesc = document.getElementById('ctl00_ContentPlaceHolder1_txtProductDesc');")

        myStr.Append("txtProductDesc.value = eventArgs.get_value();")
        myStr.Append("}")
        myStr.Append("</script>")
        Return myStr.ToString
    End Function

Webservce

<WebMethod()> _
    Public Function GetProductDescBynumber(ByVal prefixText As String, ByVal count As Integer) As String()
        Dim obj As New BusinessLayer_Test_DAAB3
        Return obj.GetProductDescBynumber(prefixText, count)'// get your data from xml or DB
    End Function

Mark as solved if it helps you !!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.