MS Ajax.NET extensions - OnTextChanged to OnKeyPress

G

Grant Merwitz

Hi

I am trying to implement the Microsoft Ajax.NET extensions to perform a
lookup on a key press of a text box.

What this will do is once a user enters a letter into the textbox,
this will filter a list from a database and populate some filtered options
for the user to choose in a seperate listbox.
Any subsequent key presses will further filter this result set.

Now utilising the OnTextChanged property of the textbox, this works
perfectly.
Except you have to tab out of the textbox to trigger the event.

So to make the on key press event work, in my Page_Load i added the
onkeypress attribute to the textbox and specified this to trigger the text
changed event.
tbSearchTerm.Attributes.Add("onkeypress",
Page.ClientScript.GetPostBackEventReference(tbSearchTerm, ""));

Now this kind of seems to work, but has a one character delay.

Example:

action: I enter the character "A" into the textbox.
result: Nothing happens

action: I enter an additional character "B" into the textbox
result: Results for the letter "A" are now returned

action: I enter my third character "C" into the textbox
result: Results for a search for letters "AB" are now returned.

This is causing a most undesirable effect.

How is one supposed to utilise an OnKeyPress action in the AJAX.Net
framework?
This was downloaded from:
http://ajax.asp.net/
And i have been unable to find another solution to this problem.

Any advice would be greatly appreciated

TIA
 
B

Ben Rush

I'm not sure I can be of much more help than sharing some code I made a
long, long time ago; back when it was still "Atlas" - I just scrounged it up
from the archives of my hard drive. So, some things may have changed a bit,
but hopefully this can give you some kind of a head start. I'm sorry, at the
moment I can't do much more due to time restrictions:

I used the AutoCompleteExtender:

<asp:TextBox ID="TextBox_ToLine"
runat="server"></asp:TextBox>
<atlas:AutoCompleteExtender ID="AutoCompleteExtender1"
ServicePath="WebService.asmx"
ServiceMethod="GetToLineSuggestions"
MinimumPrefixLength="3" runat="server">
<atlas:AutoCompleteProperties
TargetControlID="TextBox_ToLine" Enabled="true" />
</atlas:AutoCompleteExtender>

This, like a lot of ASP.Net AJAX, utilizes web services. This is the service
method that I created to handle this:

<WebMethod(EnableSession:=True)> _
Public Function GetToLineSuggestions(ByVal prefixText As String, ByVal
count As Int32) As String()
' call into stored procedure code - can't show
End Function

....sorry man, I can't give more than that at the moment.
 
G

Grant Merwitz

thanks for your advice

But I can't seem to find these components in the new framework
(atlas:AutoCompleteExtender)
I'm kind of late to these Ajax.NET extensions, and only caught on with the
latest release 1.0.

I've also managed to find several atlas solutions for this problem online,
but i can't seem to use any of them.

The only components that seem to come out the box are:
Pointer
Timer
ScriptManager
ScriptManagerProxy
UpdateProgress
UpdatePanel

I also haven't had to declare a web method or create a web service to utlise
Ajax.NET functionality.

All controls placed in the UpdatePanel, or referenced by an UpdatePanel
trigger,
will call my page methods directly without me needing to create a .asmx page
or declare a web method.

Hopefully you or someone else can advice me futher,
i've also posted on the ajax.asp.net forum, and will post my solution here
if i find one.

thanks again
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top