Master Pages, buttons, Login Control, and the default button

I've been working on a MasterPage that has a search box and search button.

When the master page loads in the Login page, the default button is set to the search button. This is not good when a user wants to press "Enter" on the username/password textbox.

I tried to do this:

<asp:Panel ID="pnlLogin" runat="server" DefaultButton="LoginButton">

    <asp:Login ID="lgnSecurity" OnAuthenticate="lgnSecurity_Authenticate" runat="server" />

</asp:Panel>

However, that didn't work and I got parser errors. I was playing and finally came up with this, which works perfectly.

lgnSecurity.Focus();
((HtmlForm)Master.FindControl("MainForm")).DefaultButton = ((Button)lgnSecurity.FindControl("LoginButton")).UniqueID;



3 Comments

Comments have been disabled for this content.