Text recognition in ASP.Net

S

SV

I am using ASP.Net / VB.Net v 2005.
I want to add text recognition to one of the text box of suburb in my
form. What I want to do is when user type any character in that text
box, one dynamic list appear under that text box having all suburb
name start with that character.
How do I achieve that? Any hints……

Any help will be appreciated.

Thanks,
SV
 
L

Leon Mayne

SV said:
I am using ASP.Net / VB.Net v 2005.
I want to add text recognition to one of the text box of suburb in my
form. What I want to do is when user type any character in that text
box, one dynamic list appear under that text box having all suburb
name start with that character.
How do I achieve that? Any hints……

Do you mean like the ajax autocomplete control?
http://asp.net/AJAX/AjaxControlToolkit/Samples/AutoComplete/AutoComplete.aspx

You just need to write a web service which will list the possible suburbs
for a given keystroke and point the control to your service.
 
S

SV

Thanks Leon,

I have downloaded AJAX Toolkit. But i am not getting any help re: How
to implement autocomplete function in my current website.

Could you help me please? I haven't used AJAX before.

I really appreciate it.

Thanks,
SV
 
S

SV

Ahh I have solved it but now another problem…….

I have made web service and consume it to my project.
Web service runs perfect individually but when I consume web service
in my project (by right click on solution explorer--> add web
references ---> add reference). I got new folder in solution explorer
name as "App_WebReferences" and under that folder i have

- App_WebReferences
- AjaxAutoCompleteWS
- AjaxAutoCompleteWS.disco
- AjaxAutoCompleteWS.discomap
- AjaxAutoCompleteWS.wsdl


I don’t know why it shows me AjaxAutoCompleteWS.wsdl and other files
Instead of AjaxAutoCompleteWS.asmx file.
In my web service, I have .asmx file and coded it into vb.net

When I am writing code in default.aspx like:

<asp:TextBox ID="TextBox1" runat="server" Width="322px"></asp:TextBox>

<ajaxToolkit:AutoCompleteExtender
runat="server"
ID="autoComplete1"
TargetControlID="TextBox1"
ServiceMethod="LookUpSuburb"
ServicePath="App_WebReferences/AjaxAutoCompleteWS/
AjaxAutoCompleteWS.wsdl"
MinimumPrefixLength="1"
CompletionInterval="1000"
EnableCaching="true"
CompletionSetCount="20"
CompletionListCssClass="autocomplete_completionListElement"
CompletionListItemCssClass="autocomplete_listItem"

CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"
DelimiterCharacters=", :;">
</ajaxToolkit:AutoCompleteExtender>


It doesn't work.
It shows me just text box. No combo box having suburb names...

Any help really appreciated

Thanks,
SV
 
L

Leon Mayne

SV said:
I don’t know why it shows me AjaxAutoCompleteWS.wsdl and other files
Instead of AjaxAutoCompleteWS.asmx file.
In my web service, I have .asmx file and coded it into vb.net

It doesn't copy the source files, it is taking a copy of the definition the
web service provides. The WSDL file is a service contract for what methods
the service provides etc:
http://en.wikipedia.org/wiki/Web_Services_Description_Language
This allows your project to create proxy dummy objects so you can access the
web methods as if you have made a local reference to a class.

As it turns out you don't need to add a web reference anyway. You just need
to change the values in the AutoCompleteExtender tag to point to wherever
the service is exposed. If it's sitting in the same web project then you can
just use:

<ajaxToolkit:AutoCompleteExtender
runat="server"
ID="autoComplete1"
TargetControlID="TextBox1"
ServiceMethod="LookUpSuburb"
ServicePath="~/PathTo/AjaxAutoCompleteWS.asmx"
etc

And if it's in a separate project then you'll have to point it to the full
URL, e.g. http://localhost/PathTo/AjaxAutoCompleteWS.asmx for testing and
then change it to wherever you're going to deploy it to before you make the
project live.
 
S

SV

Thanks for your reply Leon. I really appreciate it.

But I have tried giving direct path to my web service. But still it
doesn't work.

Now I have created new web service in my same project and assign path
to .asmx file.
When I run .asmx file it ask me for inputs and displays xml file with
strings of suburbs.
But in default.aspx file, it doesn't show me auto complete list.

I am again posting the code of AjaxAutoCompleteWS.vb file:

<WebMethod()> _
Public Function LookUpSuburb(ByVal prefixText As String, ByVal
count As Integer) As String()

count = 10
Dim sql = "select distinct name from SUBURB where name like '"
+ prefixText + "%' order by name"
Dim cn As New SqlConnection()
Dim dt As New DataSet
cn.ConnectionString =
ConfigurationManager.ConnectionStrings("Conn").ConnectionString
cn.Open()
Dim da As New SqlDataAdapter(sql, cn)
Try
da.Fill(dt, "suburb")

Finally

If Not da Is Nothing Then
da.Dispose()
End If

If Not cn Is Nothing Then

If cn.State = ConnectionState.Open Then

cn.Close()
End If
End If
cn = Nothing
End Try


Dim items(dt.Tables("suburb").Rows.Count) As String

Dim i = 0
For i = 0 To dt.Tables("suburb").Rows.Count - 1

items(i) =
dt.Tables("suburb").Rows(i).Item("name").ToString()
Next
Return items


End Function


And my deffault.aspx file contains:

<asp:TextBox ID="TextBox1" runat="server" Width="322px"></
asp:TextBox><br />
<ajaxToolkit:AutoCompleteExtender
runat="server"
ID="autoComplete1"
TargetControlID="TextBox1"
ServiceMethod="LookUpSuburb"
ServicePath="AutoAjaxDp.asmx"
MinimumPrefixLength="1"
CompletionInterval="1000"
EnableCaching="true"
CompletionSetCount="20"
CompletionListCssClass="autocomplete_completionListElement"
CompletionListItemCssClass="autocomplete_listItem"

CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"
DelimiterCharacters=", :;">
</ajaxToolkit:AutoCompleteExtender>


I don't understand that why I am not getting it.

Thanks,
SV
 
L

Leon Mayne

SV said:
<asp:TextBox ID="TextBox1" runat="server" Width="322px"></
asp:TextBox><br />
<ajaxToolkit:AutoCompleteExtender
runat="server"
ID="autoComplete1"
TargetControlID="TextBox1"
ServiceMethod="LookUpSuburb"
ServicePath="AutoAjaxDp.asmx"

Whereabouts is AutoAjaxDp.asmx in your project? Try putting the path to it
using the home (~) operator, e.g. if the asmx file is in the root folder
then use:
ServicePath="~/AutoAjaxDp.asmx"
Or if it's in a subfolder (e.g. 'Service') then use:
ServicePath="~/Service/AutoAjaxDp.asmx"
 
S

SV

Ahhh...It's still not working......

When I am putting direct path to .asmx file like "http://localhost/
AjaxAutoCompleteWS/AjaxAutoCompleteWS.asmx"
then when i am typing anything in textbox it shows me javascript error
that "Access is denied".

What shall I do now?

It’s very annoying now.
I really appreciate your replies.

Is that there is no solution for this?
 
L

Leon Mayne

SV said:
When I am putting direct path to .asmx file like "http://localhost/
AjaxAutoCompleteWS/AjaxAutoCompleteWS.asmx"
then when i am typing anything in textbox it shows me javascript error
that "Access is denied".

Don't put the full url in, just use ~/AjaxAutoCompleteWS.asmx (if that's the
name of youasmx file in the same web project as the calling page).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top