I have a master page with a form element and the defaultbutton attribute set to a server-side ImageButton. On one of my pages I want to "override" the masterpage defaultbutton attribute by setting the Forms DefaultButton in the Page_Load event.
On mater page:
<form id="form1" runat="server" defaultbutton="btnSearch">....</from>
this.Form.DefaultButton = this.ibRecalc.ID;
The DefaultButton of 'form1' must be the ID of a control of type IButtonControl
Use UniqueId. Since you can have multiple server controls with the same server id, ie, in a GridView, the framework needs to the unique id to match up to.
this.Form.DefaultButton = this.ibRecalc.UniqueID;