473,382 Members | 1,386 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

MS Ajax.NET extensions - OnTextChanged to OnKeyPress

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(tbSear chTerm, ""));

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
Mar 25 '07 #1
4 8719
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.

--
~~~~~~~~~~~
Ben Rush
http://www.ben-rush.net/blog
"Grant Merwitz" <dr********@xbox-360.co.zawrote in message
news:OO**************@TK2MSFTNGP06.phx.gbl...
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(tbSear chTerm, ""));

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

Mar 25 '07 #2
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

"Ben Rush" <kw*****@yahoo.comwrote in message
news:eZ**************@TK2MSFTNGP04.phx.gbl...
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.

--
~~~~~~~~~~~
Ben Rush
http://www.ben-rush.net/blog
"Grant Merwitz" <dr********@xbox-360.co.zawrote in message
news:OO**************@TK2MSFTNGP06.phx.gbl...
>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(tbSea rchTerm, ""));

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


Mar 26 '07 #3
Ben, you were pretty much spot on.
I needed to download the ClientScript tool kit

http://forums.asp.net/1637103/ShowThread.aspx#1637103

"Grant Merwitz" <dr********@xbox-360.co.zawrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
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

"Ben Rush" <kw*****@yahoo.comwrote in message
news:eZ**************@TK2MSFTNGP04.phx.gbl...
>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.

--
~~~~~~~~~~~
Ben Rush
http://www.ben-rush.net/blog
"Grant Merwitz" <dr********@xbox-360.co.zawrote in message
news:OO**************@TK2MSFTNGP06.phx.gbl...
>>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(tbSe archTerm, ""));

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



Mar 26 '07 #4
Grant,

If you use "onkeyup" it would return the current text

"Grant Merwitz" wrote:
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(tbSear chTerm, ""));

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
May 23 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: =?Utf-8?B?SGFyZHkgV2FuZw==?= | last post by:
Hi all, I followed first walk through sample from http://ajax.asp.net/docs/tutorials/IntroductionUpdatePanel.aspx to create my first testing page, The problem is after I clicked that botton, it...
2
by: Rahul | last post by:
I am trying the following thing in AJAX <atlas:ScriptManager ID="scriptmanager1" runat="Server" EnablePartialRendering="true" /> <asp:DropDownList ID="cmbBranchname" cssclass="Combostyle"...
4
by: pablorp80 | last post by:
Hello, Here is what I need: I need the focus and the cursor set to a textbox named txtGT, every time no matter if it is the first page load or whether it is a postback. Here is the problem: I...
6
by: progman417 | last post by:
I'm building my first little application in .net (C# - framework 3.5). So far, I've built a search page where the user enters values into text boxes, clicks a button and it displays a grid of...
5
by: simon | last post by:
hello, I have a server set up on my local (home) network and can not get an ajax application to run on the box. it works fine on our developement server and also works fine locally. I...
11
by: Jonathan Wood | last post by:
Can anyone point me to any good resources on adding AJAX to a page once the page has already been created? I know VS2008 has options to add AJAX pages, but I didn't select those options when the...
4
by: Peter | last post by:
ASP.NET I have an application which use ASP.NET Autocomplete extender which works great. But I have a question how to update all the fields on the screen using Ajax. Users starts typing in a...
1
by: Mark B | last post by:
This is my first try at using AJAX. I want the calendars to be enabled if the user checks CheckBox1. It works OK for a normal all page refresh but once I introduced the AJAX code it stopped...
1
by: Yan | last post by:
Hi, I'm apparently far from being the 1st one to meet this error... My asp.net ajax page requires ScriptManager.axd but gets a 404. following a lot of "This is how I solved it" posts, I : -...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.