3

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

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.

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)

Is there any non-JavaScript solution for getting the Return key to submit the proper, currently focused portion of the form?

4

2 に答える 2

8

パネルコントロールを使用すると、その内容の範囲内でデフォルトのボタンを定義できます。

<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>
于 2011-06-13T20:15:08.827 に答える
1

デフォルトのボタンは、今夜あなたの友達のように聞こえます - http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlform.defaultbutton.aspx

実際にはそうではないかもしれません.Javascriptなしで試したことはありません.

于 2011-06-13T20:09:15.097 に答える