I'm using the AutoCompleteExtender which is awesom. However, I've had two major issues. One is that you can make the extender hold focus on the textbox with some css (that took a few days to find) secondly and my remaining problem which only occurs when
I publish the project. It works flawlessly while running in Visual Studio.
Probably best to show you what the problem is as it's hard to describe!
Would someone do me the favour of going here: (removed link due to SEO) "www dot car buying advisor dot co dot uk" the first field (delaer name) has an auto complete extender. If you start typing say "fleet..." and wait, rather than matching the results
on the database to Fleet, the autoextender returns a long list of single chars which is the HTML you get when you browse to the .asmx service!
can you please share the complete code your web service and the way you are attaching your textbox to web service,.
Ashutosh Pathak
Blog: http://catchcode.blogspot.com Please mark it as answer if it helps, as clicking on the button can save time of others :)
MCP,MCAD,MCSD,MCTS
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Collections.Generic
Imports System.Data.SqlClient
Imports System.Data
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
<System.Web.Script.Services.ScriptService()> _
<WebService(Namespace:="http://www.carbuyadvisor.co.uk/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class autocomplete
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function DealerAutoComplete(ByVal prefixText As String, ByVal count As Integer) As String()
Dim sSuggestions As New List(Of String)
' Connection string stuff, get the connection string from the web.config file
Dim ConnString = ConfigurationManager.ConnectionStrings("sql")
Dim ConnectionString As String = ConnString.ConnectionString
Dim DBConn As SqlConnection
Dim DBCommand As SqlDataAdapter
DBConn = New SqlConnection(ConnectionString)
Dim myDataSet As New DataSet
DBCommand = New SqlDataAdapter("select top " + count.ToString + " field from table where field like @Prefix", DBConn) ' order by field
DBCommand.SelectCommand.Parameters.AddWithValue("@Prefix", String.Format("%{0}%", prefixText))
DBCommand.Fill(myDataSet, "Results")
DBConn.Close()
For count = 0 To myDataSet.Tables("Results").Rows.Count - 1
sSuggestions.Add(myDataSet.Tables("Results").Rows(count).Item(0).ToString)
Next
Return sSuggestions.ToArray
End Function
<WebMethod()> _
Public Function TownCounty(ByVal prefixText As String, ByVal count As Integer) As String()
Dim sSuggestions As New List(Of String)
' Connection string stuff, get the connection string from the web.config file
Dim ConnString = ConfigurationManager.ConnectionStrings("sql")
Dim ConnectionString As String = ConnString.ConnectionString
Dim DBConn As SqlConnection
Dim DBCommand As SqlDataAdapter
DBConn = New SqlConnection(ConnectionString)
Dim myDataSet As New DataSet
DBCommand = New SqlDataAdapter("select top " + count.ToString + " Town from table where Town like '%" + prefixText + "%' union select top " + count.ToString + " County from database where County like '%" + prefixText + "%'", DBConn)
DBCommand.Fill(myDataSet, "Results")
DBConn.Close()
For count = 0 To myDataSet.Tables("Results").Rows.Count - 1
sSuggestions.Add(myDataSet.Tables("Results").Rows(count).Item(0).ToString)
Next
Return sSuggestions.ToArray
End Function
End Class
Hope this helps. As i say it works fine in development - on various machines.
at one go, it seems okay. Did you check the data your web service is returning, i mean your DealerAutoComplete method in web service, is it returning correct data as array ?
Ashutosh Pathak
Blog: http://catchcode.blogspot.com Please mark it as answer if it helps, as clicking on the button can save time of others :)
MCP,MCAD,MCSD,MCTS
your web service is fine, also the code. I think it could be an deploymenet issue, did you copied the complete code, can you try the same using XCOPY deployment on production instead of Published code.
Ashutosh Pathak
Blog: http://catchcode.blogspot.com Please mark it as answer if it helps, as clicking on the button can save time of others :)
MCP,MCAD,MCSD,MCTS
i mean to say, can you directly copy ur code to production instead of publishing it. i just want to know if that works or not.
Ashutosh Pathak
Blog: http://catchcode.blogspot.com Please mark it as answer if it helps, as clicking on the button can save time of others :)
MCP,MCAD,MCSD,MCTS
rngDeadeye
0 Points
9 Posts
First Post - Pulling my hair out
Oct 31, 2012 09:02 AM|LINK
Hi
I'm using the AutoCompleteExtender which is awesom. However, I've had two major issues. One is that you can make the extender hold focus on the textbox with some css (that took a few days to find) secondly and my remaining problem which only occurs when I publish the project. It works flawlessly while running in Visual Studio.
Probably best to show you what the problem is as it's hard to describe!
Would someone do me the favour of going here: (removed link due to SEO) "www dot car buying advisor dot co dot uk" the first field (delaer name) has an auto complete extender. If you start typing say "fleet..." and wait, rather than matching the results on the database to Fleet, the autoextender returns a long list of single chars which is the HTML you get when you browse to the .asmx service!
<
H
T
M
L
>
<
H
E
A
D
>
Etc...
Please help me before I shoot myself.
Ashutosh Pat...
Contributor
5737 Points
1105 Posts
Re: First Post - Pulling my hair out
Oct 31, 2012 09:40 AM|LINK
can you please share the complete code your web service and the way you are attaching your textbox to web service,.
Blog: http://catchcode.blogspot.com
Please mark it as answer if it helps, as clicking on the button can save time of others :)
MCP,MCAD,MCSD,MCTS
rngDeadeye
0 Points
9 Posts
Re: First Post - Pulling my hair out
Oct 31, 2012 10:10 AM|LINK
Hi
HTML Source:
<asp:TextBox class="txtSearch" ID="txtSearchDealerName" runat="server"></asp:TextBox> <ajaxToolkit:AutoCompleteExtender runat="server" TargetControlID="txtSearchDealerName" ID="autoComplete" ServicePath="~/autocomplete.asmx" ServiceMethod="DealerAutoComplete" MinimumPrefixLength="2" CompletionSetCount="8" EnableCaching="true" CompletionInterval="10" CompletionListCssClass="completeListLong" CompletionListItemCssClass="completeItem" CompletionListHighlightedItemCssClass="completeHighlight" > <Animations> <OnShow> <Sequence> <HideAction Visible="true"></HideAction> <FadeIn Duration=".30" Fps="20"/> </Sequence> </OnShow> <OnHide> <Sequence> <HideAction Visible="true"></HideAction> <FadeOut Duration=".20" Fps="20"/> </Sequence> </OnHide> </Animations> </ajaxToolkit:AutoCompleteExtender> <ajaxtoolkit:TextBoxWatermarkExtender ID="txtSearchDealerName_TextBoxWatermarkExtender" runat="server" Enabled="True" TargetControlID="txtSearchDealerName" WatermarkCssClass="watermark" WatermarkText="Dealer name"> </ajaxtoolkit:TextBoxWatermarkExtender>autocomplete.vb
Imports System.Web Imports System.Web.Services Imports System.Web.Services.Protocols Imports System.Collections.Generic Imports System.Data.SqlClient Imports System.Data ' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. <System.Web.Script.Services.ScriptService()> _ <WebService(Namespace:="http://www.carbuyadvisor.co.uk/")> _ <WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _ <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Public Class autocomplete Inherits System.Web.Services.WebService <WebMethod()> _ Public Function DealerAutoComplete(ByVal prefixText As String, ByVal count As Integer) As String() Dim sSuggestions As New List(Of String) ' Connection string stuff, get the connection string from the web.config file Dim ConnString = ConfigurationManager.ConnectionStrings("sql") Dim ConnectionString As String = ConnString.ConnectionString Dim DBConn As SqlConnection Dim DBCommand As SqlDataAdapter DBConn = New SqlConnection(ConnectionString) Dim myDataSet As New DataSet DBCommand = New SqlDataAdapter("select top " + count.ToString + " field from table where field like @Prefix", DBConn) ' order by field DBCommand.SelectCommand.Parameters.AddWithValue("@Prefix", String.Format("%{0}%", prefixText)) DBCommand.Fill(myDataSet, "Results") DBConn.Close() For count = 0 To myDataSet.Tables("Results").Rows.Count - 1 sSuggestions.Add(myDataSet.Tables("Results").Rows(count).Item(0).ToString) Next Return sSuggestions.ToArray End Function <WebMethod()> _ Public Function TownCounty(ByVal prefixText As String, ByVal count As Integer) As String() Dim sSuggestions As New List(Of String) ' Connection string stuff, get the connection string from the web.config file Dim ConnString = ConfigurationManager.ConnectionStrings("sql") Dim ConnectionString As String = ConnString.ConnectionString Dim DBConn As SqlConnection Dim DBCommand As SqlDataAdapter DBConn = New SqlConnection(ConnectionString) Dim myDataSet As New DataSet DBCommand = New SqlDataAdapter("select top " + count.ToString + " Town from table where Town like '%" + prefixText + "%' union select top " + count.ToString + " County from database where County like '%" + prefixText + "%'", DBConn) DBCommand.Fill(myDataSet, "Results") DBConn.Close() For count = 0 To myDataSet.Tables("Results").Rows.Count - 1 sSuggestions.Add(myDataSet.Tables("Results").Rows(count).Item(0).ToString) Next Return sSuggestions.ToArray End Function End ClassHope this helps. As i say it works fine in development - on various machines.
Ashutosh Pat...
Contributor
5737 Points
1105 Posts
Re: First Post - Pulling my hair out
Oct 31, 2012 10:26 AM|LINK
at one go, it seems okay. Did you check the data your web service is returning, i mean your DealerAutoComplete method in web service, is it returning correct data as array ?
Blog: http://catchcode.blogspot.com
Please mark it as answer if it helps, as clicking on the button can save time of others :)
MCP,MCAD,MCSD,MCTS
rngDeadeye
0 Points
9 Posts
Re: First Post - Pulling my hair out
Oct 31, 2012 11:38 AM|LINK
It works perfectly in dev which is connected to that live database
This is what you get once it's published to iis
Ashutosh Pat...
Contributor
5737 Points
1105 Posts
Re: First Post - Pulling my hair out
Oct 31, 2012 12:18 PM|LINK
your web service is fine, also the code. I think it could be an deploymenet issue, did you copied the complete code, can you try the same using XCOPY deployment on production instead of Published code.
Blog: http://catchcode.blogspot.com
Please mark it as answer if it helps, as clicking on the button can save time of others :)
MCP,MCAD,MCSD,MCTS
rngDeadeye
0 Points
9 Posts
Re: First Post - Pulling my hair out
Oct 31, 2012 01:18 PM|LINK
Not sure what you mean mate?
For info I publish the project directly to a the folder that IIS is publishing as the site and I have "allow this site to be updateable" turned off.
Ashutosh Pat...
Contributor
5737 Points
1105 Posts
Re: First Post - Pulling my hair out
Oct 31, 2012 03:58 PM|LINK
i mean to say, can you directly copy ur code to production instead of publishing it. i just want to know if that works or not.
Blog: http://catchcode.blogspot.com
Please mark it as answer if it helps, as clicking on the button can save time of others :)
MCP,MCAD,MCSD,MCTS
rngDeadeye
0 Points
9 Posts
Re: First Post - Pulling my hair out
Oct 31, 2012 04:05 PM|LINK
What, just copy the web project folder!?
I didn't nkow you could do that
I'll try that.
Just to add, as part of going live, I've published it to a completely new server and the issue remains so your suggestion is encouraging.
rngDeadeye
0 Points
9 Posts
Re: First Post - Pulling my hair out
Oct 31, 2012 04:18 PM|LINK
Nope, still doesn't work.