title: ASP.NET Master page DefaultButton override
body: <p>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.</p>
  
  <p>i.e 
  On mater page:</p>
  
  <pre><code>&lt;form id="form1" runat="server" defaultbutton="btnSearch"&gt;....&lt;/from&gt;
  </code></pre>
  
  <p>On the page Page_Load event that "override" the master page attribute:</p>
  
  <pre><code>this.Form.DefaultButton = this.ibRecalc.ID;
  </code></pre>
  
  <p>It errors with :</p>
  
  <blockquote>
    <p>The DefaultButton of 'form1' must be the ID of a control of type IButtonControl</p>
  </blockquote>
  
  <p>I am using image buttons which implements IButtonControl</p>
  
  <p>Any ideas of what I might be doing wrong or a different way to approach the problem?</p>
  
  <p>Thanks</p>