Textboxes and autopostbacks

A

Alex Shirley

Hi

On my webform I have a textbox in which autopostback is set to true. (nb
I don’t want to disable this because I have manipulating the visibility
of other controls, but for the purposes of the exercise I’ve stripped
that code out for the time being).

What’s happening

a) If I click the submit button on the web form then the submit buttons
click event is triggered [which is good].

If I click on the textbox set to autopostback, then click on another
textbox not set to autopostback, the submit buttons click event is
triggered [which still is good].

However….
If I click on the textbox set to autopostback, and then immediately
click the submit button, then that buttons click event is not triggered
[which is bad]. I have to press the submit button again to trigger the
click event. It’s as if there are two postback events which are being
queued here.

Any ideas on how to solve this (I’m using asp.net/vb)?

Many Thanks

Alex

p.s.
I appear to be posting every day here. Sorry about this, I’m pretty new
to these “complex” forms. I’m RTFM’ing the manual but still getting
nowhere sometimes.
 
S

S. Justin Gengo

Alex,

Here's what I would do.

Instead of using the text box's autopost back feature, which submits the
form, I would attach a javascript to the textbox that clicks the button
instead. It would look like this:

MyTextBox.Attributes.Add("onChange", "javascript:document.Form1." &
MyButton.ClientID & ".click();")

I think that will solve your problem.
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
B

bruce barker

there are two postbacks happening

1) click on textbox - browser start postback
2) click on submit before postback response, browser will post again.


if you are fast clicking on the submit, you can get server postbacks going
at once. the browser will ignore all but the last, but the server will fully
process all of them.


-- bruce (sqlwork.com)
 

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,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top