ASP.NET Enter Button Submit Problem Workaround

Sorry for the weird title, but I wanted something short and keyword-heavy to help people find this information via Google search.

Anyway, I’m currently working on sharpening my .NET skills and recently began a very project that starts with a very simple login page. Two fields (name and password) and a “Submit” button. Much to my surprise, having made a bazillion pages like this with ColdFusion and PHP, hitting Enter on the .NET version does NOT submit the form. Apparently, this is a “feature” of the way ASP.NET pages work. And it’s one of those things that, from an engineering standpoint, makes perfect sense, though usability-wise is completely unacceptable.

Anyway, if you’re reading this, you probably got here via a Google search and know exactly what I’m talking about (unless you’re just a friend who reads everything I post, in which case I apologize for the geekery), so here’s a solution that someone - Darrell Norton - came up with.

Leave a Reply