Setting the default botton that needs to be pushed when the Enter key is pressed into an ASPX page, can be implemented easly in Asp.Net.
Imagine that your page holds 2 controls:
- a Asp.net TextBox named tb1
- a Asp.net Button named btn1
To instruct the page, to point the default button on btn1, you should use:
Page.Form.DefaultButton = btn1.ClientID;
Setting the focus on tb1 can be accomplished by:
Page.Form.DefaultFocus = tb1.ClientID;
As you can see, you have to use control's ClientID and not the control's ID.
But what happens if you want to set the Page's DefaultButton property to a login button contained in a Login form control? Consider surrounding the <asp:Login /> control with a simple asp.net Panel:
<asp:Panel ID="Panel1" runat="server" Height="100%" Width="100%" DefaultButton="llogin$LoginButton">
<asp:Login ID="llogin" runat="server"
PasswordRecoveryUrl="~/passwordrecover.aspx"
CreateUserUrl="~/register.aspx"
TitleTextStyle-CssClass="contentGroupHeader"
OnLoggedIn="SetCookie" >
<LoginButtonStyle CssClass="button" ></LoginButtonStyle>
</asp:Login>
</asp:Panel>
...and set the DefaultButton property using the syntax provided in the example.