TextChanged eats up Button Click event problem

Q

Quickstone

Hi Andre.

I've tried a sample using your description. You said that
when you typed in something into the textbox with
AutoPostBack = True, and pressed a button the Page_Load,
TextChanged, Button.Click occurred. How is that possible?
Are you sure you didn't change the text in one of the
textboxes what did not have the AutoPostBack=True?

The reason why I'm questioning this (and I tried it my
self), is that when you change anything in the textbox
(containing the AutoPostback=true) and as soon as click
away from there (doesn't matter what button you press on
the form), the only event that will be raised is the
Textbox change (so despite that you clicked on your
button, it will never be raised) - rules of JavaScript.

I tried this my self, and I did a Code stepthrough with
VS.NET 2003 debugger and works like I expected.

If you are having this problem like you are saying, I
would like to know more what exactly you are doing, so
that I can possibly help you. Post some code here for us
to see, and maybe there is a problem that is deeper than
that.

Hope that helps
 
A

Andre

Hi,

Thank you very much for the prompt answer. You are quite right after attempt
to retest described by me code behaviour I found that button Click event
never gets called. I have seen somewhere on internet mentioning that in my
situation TextChanged and Click should get chained and called in appropriate
order. I have seen this "correct" behaviour in my VS.Net 2003 in debugger,
but because I can not repeat it, I think it was either lack of concentration
or some misunderstanding from me.
Anyway I would rephrase my original question. Is it possible to alter this
standard behavior, as in my situation, user changes value in one of the form
fields and hits "Clear" button and instead of getting clear form he gets some
data loaded into the form, which is obviously considered by user as a
software bug.
I briefly explain form behaviour (note that I have about 100+ forms with
same type of behaviour). Form contains textboxes, listboxes, checkboxes, etc.
and two buttons : Save and Clear. One of textboxes is "ID" and when user
enters some ID in this field form performs postback and if there is such ID
in the DB it populates rest of the form with the values. When user clicks on
Clear button form is expected to be cleared.
Thanks in advance.

Regards,
Andre.
 
Q

Quickstone

hmm... I see what you're trying to do. I'd expect it to
work (as a user) just the way you described it. Now. I
see few options that you have. Because your textbox has
autopostback=true, as mentioned earlier, as soon as you
change a value in it, it will cause an event, and your
buttons will never be clicked (as far as the program is
concerned). So you will have to work around it probably.
One way (the simplest) is to set autopostback=false of
the textbox, and add another button "LOAD RECORD" which
will take the value of the textbox (ID) and load rest of
the fields. But I'm sure you already though about it, and
it may not be an option to you. Second option is, if you
really want to make it work the way you were mentioning
is to add OnClick event (javascript) to your textbox
control, which will Disable the Clear button and save
button. And then add the OnMouseOut event (also
javascript) that will call a javascript function that
will enable your clear and save buttons. That way, while
sill in the ID box, you cannot click the clear button or
the save button. At least the system will not work
against user expectations.

Hope that helps.
 
I

Israel

hi,
I have the same problem with the RequiredFieldValidator, they are not
working fine the errormessage is not shown and this is why the button dosen't
submit.
If you fill all your fields with valid values and press the button you will
see that the event is fire.
so the problem is with the errormessage not shown.
and this is also started to me after I installed xp sp2, I think the problem
related to this.
hope to find solution soon.
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top