Well, you are really stretching it here, as associated an action to the button. Don't do that. There is simply no way to reliably guarantee that everything will work as you expect, if you mix scripting design-time form with the runtime actions.
Set the button properties manually or simply move the button out of the form if you need actions to be supported.