Dave
Dave

Reputation: 493

ASP.Net C# - ignoring phone keyboard Enter button on form

I'm doing a mobile version of an existing ASP.Net site, just re-doing the layouts to make it mobile friendly, not making a web app or anything. I have a textbox where people can enter some optional text, but if you hit enter on the on-screen keyboard it's firing a button which I don't want to happen.

I've tried setting up a panel with a default button, but it's not working on the Android phone I'm trying it on:

<asp:Panel id="wrapper" runat="server" DefaultButton="decoy">
...
    <asp:Button ID="addtobasket" runat="server" oncommand="a2b_Command" Text="Add to basket" class="addtobasket uppercase" />
    <asp:Button ID="decoy" runat="server" Visible="false" />
...
</asp:Panel>

Is it the fact that I'm having to hide the decoy button? It still fires a postback when you click the enter key if it's not hidden, so is there a straightforward way of preventing this? I just need the keyboard to close.

Any ideas appreciated.

Upvotes: 0

Views: 501

Answers (1)

Jason Coyne
Jason Coyne

Reputation: 6636

Disable/dont set the default button all together if you are on a mobile browser?

Upvotes: 0

Related Questions