ASP.NET enter key and form submit with no javascript

和自甴很熟 提交于 2019-12-06 15:46:42

The fix for this is what was listed in the bottom of the page of your linked post. IE needs to have an additional form field for some reason for this to work. I have used this in many projects, and it gets around the bug. Just add the following.

<!-- Fix for IE bug submit on pressing "Enter") -->
<div style="display:none">
            <input type="text" name="hiddenText"/>
</div>
Paulo Fagundes

My solution was this, a script that does click the login button.

Worked in all browsers!

public partial class Logon : UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Page.ClientScript.RegisterClientScriptBlock(GetType(), "Logon", "document.getElementById('id_LoginButton').click();", true);
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!