Textbox change

  • Thread starter Thread starter ruca
  • Start date Start date
R

ruca

Hi,

I have a textbox that when I write something there that she runs a function.
For that I use the method:
[textboxname]_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles [textboxname].TextChanged
I put in textbox properties the AutoPostBack = true.

The problem is that I write something in texbox but it only runs the
function when textbox lost focus.
Suggestions? Solutions? Comments? Anything else? I apreciate.
 
This is the normal behaviour. If you look at the generated HTML, the
javascript onChange event handler is used to do the postback. Some
documentation on the web for this handler states "A change event occurs when
a select, text, or textarea field loses focus and its value has been
modified. The onChange event handler executes JavaScript code when a change
event occurs.", so it can only occur when it loses focus.

I don't know if its possible to do what you want in javascript (if it was
you would need to write an ASP.NET custom control), but imagine if it posted
back to the server every time you typed a character - it might make your app
unusable.

Hope that explains why it is behaving like that,

Cheers,
Pete Beech
 
Thanks Pete.
I think I've got the point, and I think you have right too when you said:

"...but imagine if it posted back to the server every time you typed a
character - it might make your app unusable."

I search in Web things and like I said before I think you've got reason.

Thank's man. I apreciate your opinion.


--
Programming ASP.NET with VB.NET
Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca


P.S. - But if anyone have a different opinion post it. I accept all opinions




Pete Beech said:
This is the normal behaviour. If you look at the generated HTML, the
javascript onChange event handler is used to do the postback. Some
documentation on the web for this handler states "A change event occurs when
a select, text, or textarea field loses focus and its value has been
modified. The onChange event handler executes JavaScript code when a change
event occurs.", so it can only occur when it loses focus.

I don't know if its possible to do what you want in javascript (if it was
you would need to write an ASP.NET custom control), but imagine if it posted
back to the server every time you typed a character - it might make your app
unusable.

Hope that explains why it is behaving like that,

Cheers,
Pete Beech

ruca said:
Hi,

I have a textbox that when I write something there that she runs a function.
For that I use the method:
[textboxname]_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles [textboxname].TextChanged
I put in textbox properties the AutoPostBack = true.

The problem is that I write something in texbox but it only runs the
function when textbox lost focus.
Suggestions? Solutions? Comments? Anything else? I apreciate.


--
Programming ASP.NET with VB.NET
Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca
 
Hi,

that is client-side behaviour as it is 'onchange' attribute that contains
the needed __doPostBack js call. If you want to modify this, you need to add
custom attribute to client-side where you'd call the same __doPostBack
function to cause postback as result of different client-side event.
Page.GetPostBackEventReference helps you in creating the js _doPostBack call
(ensures that Page Framework has __doPostBack function registered).

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke



Hi,

I have a textbox that when I write something there that she runs a function.
For that I use the method:
[textboxname]_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles [textboxname].TextChanged
I put in textbox properties the AutoPostBack = true.

The problem is that I write something in texbox but it only runs the
function when textbox lost focus.
Suggestions? Solutions? Comments? Anything else? I apreciate.
 
Back
Top