Postback event not firing on FIRST button click..

Posted by ClarkeyBoy on Stack Overflow See other posts from Stack Overflow or by ClarkeyBoy
Published on 2010-04-16T16:40:57Z Indexed on 2010/04/16 16:43 UTC
Read the original article Hit count: 500

Filed under:
|
|
|
|

Hi,

I have a form which accepts two arguments. The first one is mode - this is either view, new or edit. If it is new then the second argument is type - this is either range, collection or design. When set to new, and the type is valid, a new instance of that type is created and the data from the form is added to it. The item (range, collection or design) then validates the data. If any of the data is invalid then it throws an error, and this error is displayed at the top of the form telling the user why it is invalid. A variable, _Databind, is set to false so that it does not change the data input by the user (in the form fields).

The button used to submit the button is called btnSave, and is created in the html source. The click event is wired up in the form Protected Sub Blah(sender, e) Handles btnSave.Click. Strangely, whenever I edit an item that already exists the form submits fine the first time - the click event is fired. However when in "new" mode I have to click the button twice to fire the event. It also blanks all the form fields out on first click.

I have even put a Response.Write("Hello World") line at the start of the click event - this is not being output on first click when adding a new item either. It is on first load when the mode is set to edit however.

Does anyone have any ideas as to what is causing it to behave this way?

Thanks in advance for any help.

Regards,

Richard

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about .NET