Submit by hitting enter

I am wondering why this, sending on press enter, only works on ie and not on google chrome ...

This is the code I'm actually using:

<div class="TxtBox">
        <asp:Panel ID="lepanel" runat="server" DefaultButton="Connect">
            <asp:TextBox ID="TxtUserLogin" runat="server" TabIndex="1" Text="login" />
            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="*"
                Display="Static" ControlToValidate="TxtUserLogin"></asp:RequiredFieldValidator>
            <asp:TextBox ID="UserPass" runat="server" TabIndex="2" Text="password" TextMode="Password" />
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*"
                Display="Static" ControlToValidate="UserPass"></asp:RequiredFieldValidator>
            <asp:LinkButton ID="Connect" runat="server" OnClick="Connect_Click" TabIndex="3">connect</asp:LinkButton>
        <asp:Label ID="MsgError" runat="server" />
        <div class="ForgottenPass">
            forgotten password ?
        <div class="RememberMe">
            <asp:CheckBox runat="server" ID="chkBoxRemember" />
            stay signed in



source to share

2 answers

This is a known issue where you add a default link (actually a link) and not a real button, then there is a case that doesn't fire properly.

So, if you change it to a real button, you run it.



A is LinkButton

rendered as an HTML anchor tag.

HTML anchor tags do not submit HTML forms. So when you click Enterit is not a submit button action.

A is Button

rendered as HTML<input type="submit" />

An ImageButton

renders as HTML<input type="image" />

These elements will act as your form.

Therefore, changing the best solution LinkButton

is Button

or ImageButton


Usage is LinkButton

also bad for users who don't have javascript.



All Articles