[英]WebForms submitting specific form with enter key (not clicking)
Say I have one full-page form, but within the form, there are two or more events that need to take place on submission: Login
& Register
假设我有一个整页表单,但在表单中,提交时需要发生两个或多个事件:
Login
和Register
Site.Master: Site.Master:
<%@ Master Language="C#" AutoEventWireup="true"
EnableViewState="true" CodeBehind="Site.Master.cs"
Inherits="Site.SiteMasterPage" %>
<!doctype>
<html>
<head runat="server">
<%-- stuff --%>
</head>
<body>
<form ID="MainForm" action="" runat="server">
<asp:Login id="LoginControl" runat="server" />
<asp:CreateUserWizard id="RegisterControl" runat="server" />
</form>
</body>
</html>
If my cursor is focused inside of an input type="text"
for asp:Login
, and I hit Return (with javascript off), the page submits, but I am not logged in.如果我的 cursor 聚焦在
asp:Login
的input type="text"
内,然后我点击Return (关闭 javascript),页面提交,但我没有登录。
The same thing happens when I attempt to register (filling out the createUserWizard and hitting the Return key instead of actually clicking "Register", firing some event)当我尝试注册时也会发生同样的事情(填写 createUserWizard 并按Return键,而不是实际单击“Register”,触发一些事件)
Is there any non-JavaScript solution for getting the Return key to submit the proper, currently focused portion of the form?是否有任何非 JavaScript 解决方案可以让Return键提交正确的、当前关注的表单部分?
The panel control allows you to define a default button within the scope of it's contents:面板控件允许您在其内容的 scope 中定义默认按钮:
<asp:Panel runat="server" DefaultButton="submitButtonA">
<asp:LinkButton ID="submitButtonA" runat="server" Text="Submit A"/>
</asp:Panel>
<asp:Panel runat="server" DefaultButton="submitButtonB">
<asp:LinkButton ID="submitButtonB" runat="server" Text="Submit A"/>
</asp:Panel>
The default button sounds like it might be your friend tonight - http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlform.defaultbutton.aspx默认按钮听起来可能是你今晚的朋友 - http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlform.defaultbutton.aspx
Actually it might not be, I haven't ever tried it with no Javascript.实际上可能不是,我从来没有尝试过没有 Javascript。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.