Mert
Mert

Reputation: 99

Asp.net Textbox.Autopostback causes another issue

I have dropdown and texboxes and one button on the form. I'm using 'autopostback=true' for all the form elements. When you fill the form you need to push 'send' button. But because of texbox.autopostback, you need to push 2 time to send form.

If you select dropdown lastly, then there is no problem. But if you're filling textboxes than you need to click 2 time to send form.

Is there any solution for it? I must use textboxes.autopostback='true' but need some solution.

Thanks,

UPDATE:

All controls stays in updatepanel element.

Upvotes: 1

Views: 989

Answers (1)

Sunil
Sunil

Reputation: 21396

  • Set a hidden field value to "1" when textbox posts back and its value is valid, else set the hidden field value to "0"
  • On client-side, in pageLoad event, automatically click the button if the hidden field value is "1". So, to the user button is only clicked once and your auto submitting the form when text post back returns.

Both the above points need to be done in your code-behind.

The result of of this logic will enforce a consistent workflow, where the button can be clicked only once to submit the page.

Upvotes: 1

Related Questions