autopostback on text box

M

Mike Malone

I have a web form with a text control and button. The text control has the autopostback set to true so I can take a action when the text box has data typed into it.

The problem is that I also have a button and when the button is clicked I just get the textchanged message but no button click message.

How can I tell in the textchanged function that the button was clicked so I can fire the button click code or get the post back to include the click in the first place?

- Mike
 
J

Jos

Mike said:
I have a web form with a text control and button. The text control
has the autopostback set to true so I can take a action when the text
box has data typed into it.

The problem is that I also have a button and when the button is
clicked I just get the textchanged message but no button click
message.

How can I tell in the textchanged function that the button was
clicked so I can fire the button click code or get the post back to
include the click in the first place?

- Mike

By design, the textchanged handler is supposed to fire first, and the
buttonclick
second.

I'm surprised that your buttonclick doesn't fire at all. Are you sure the
onclick
attribute is set to the handler and that your button has the runat="server"
attribute?
 
M

Mike Malone

The problem comes when you turn on the autopostback feature of the text box. I only get one message back from the textbox that being the textchanged message. I don't get the button fire event.

What is it about the textbox autopostback that causes the button event to not be fired?

- Mike
Jos said:
I have a web form with a text control and button. The text control
has the autopostback set to true so I can take a action when the text
box has data typed into it.

The problem is that I also have a button and when the button is
clicked I just get the textchanged message but no button click
message.

How can I tell in the textchanged function that the button was
clicked so I can fire the button click code or get the post back to
include the click in the first place?

- Mike

By design, the textchanged handler is supposed to fire first, and the
buttonclick
second.

I'm surprised that your buttonclick doesn't fire at all. Are you sure the
onclick
attribute is set to the handler and that your button has the runat="server"
attribute?
 
J

Jos

Mike said:
The problem comes when you turn on the autopostback feature of the
text box. I only get one message back from the textbox that being the
textchanged message. I don't get the button fire event.

What is it about the textbox autopostback that causes the button
event to not be fired?

- Mike

I guess that, when you click the button, the textbox loses focus first, and
therefore posts back immediately. The button click is not handled anymore,
since the form has been posted already.

I guess you'll have to remove the autopostback, and wait for the user to
push the button. But I'm afraid that's not what you want :-(
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top