asp.netauthenticationdefaultbutton

asp:login default button doesn't work


i'm trying to set a default button to my login control, and after reading several similar questions i learned about the panel default button using the login controls ID

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

which works fine for simple logincontrols, however is doesn't work with my login control, i'm thinkinng it has something to do with me using a layout template. Can anyone tell me why it isn't working.

my login:

<asp:Panel runat="server" ID="pnlLogin" DefaultButton="LoginUser$LoginButton">
<asp:Login ID="LoginUser" runat="server" EnableViewState="False" Width="371px">
    <LayoutTemplate>
        <span class="failureNotification">
            <asp:Literal ID="FailureText" runat="server"></asp:Literal>
        </span>
        <asp:ValidationSummary ID="LoginUserValidationSummary" runat="server" CssClass="failureNotification" 
             ValidationGroup="LoginUserValidationGroup"/>

            <table width="100%" border="0">                
                <tr>
                    <td style="width: 95px; height: 30px;">
                        <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">Brugernavn:</asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="UserName" runat="server" CssClass="textEntry"></asp:TextBox><asp:RequiredFieldValidator
                            ID="UserNameRequired" runat="server" ControlToValidate="UserName" CssClass="failureNotification"
                            ErrorMessage="Brugernavn kræves udfyldt" ToolTip="Brugernavn kræves udfyldt"
                            ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>                        
                        <td style="width: 95px; height: 30px;">
                            <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Adgangskode:</asp:Label>
                        </td>
                        <td>
                            <asp:TextBox ID="Password" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password"
                                CssClass="failureNotification" ErrorMessage="Adgangskode kræves udfyldt" ToolTip="Adgangskode kræves udfyldt"
                                ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>
                        </td>                       
                </tr>
                <tr>
                    <td style="width: 95px; height: 50px;" valign="bottom">
                        <asp:LinkButton runat="server" ValidationGroup="LoginUserValidationGroup" CommandName="Login"
                            ID="LoginButton" CssClass="button">Log ind</asp:LinkButton>
                    </td>
                    <td style="height: 50px;" valign="bottom">
                        <asp:CheckBox ID="RememberMe" runat="server" />
                        <asp:Label ID="RememberMeLabel" runat="server" AssociatedControlID="RememberMe" CssClass="inline">Husk mig, når jeg kommer tilbage</asp:Label>
                    </td>
                </tr>                             
            </table>


                <br />
            <br />

    </LayoutTemplate>
</asp:Login>
</asp:Panel>     

Solution

  • You can't use a LinkButton as a default button

    From MSDN Panel.DefaultButton Property

    The DefaultButton can be set to the identifier for a Button control or any control that implements the IButtonControl interface except a LinkButton control.