Set "Default" button programmatically

Sometimes you have two buttons that you want to have as the "Default" button based on different conditions. For example, if you have a screen with basic and advanced search, you want the "Search" button to be the default button, but you have a different "Seach" button in the If.

The style is the easier part - it can be easily applied by adding the Is_Default class name to the button. This works for submit buttons and for links as well.

The handling of the enter key should be a little trickier. But it could be done by including a "dummy" default button, and then writing the onclick extended property to delegate the click on the real (programmatically calculated) default button. Something along these lines: