简体   繁体   English

使用多个表单,在ASP.NET Web表单页面上提交按钮

[英]Using multiple forms, submit buttons on an ASP.NET web forms page

在此输入图像描述

I have 3 different submit buttons(Log In, Search, Insert) in the same page and what I want is to find the best way to have this 3 buttons doing a different things when I press them, or I press enter while I am about to press them. 我在同一页面上有3个不同的提交按钮(登录,搜索,插入),我想要的是找到按下它们时让这3个按钮执行不同操作的最佳方法,或者在我关注时按Enter键按下它们。 As you can see from my photo, when I press Log In the Insert is pressed too because I have a global form in my Master Page. 从我的照片中可以看出,当我按下Log In ,也会按下Insert,因为我的母版页中有一个global form

I tried to use different forms, but i can't because I need them to have runat="server" , which is not possible for a page to have. 我尝试使用不同的表单,但我不能,因为我需要它们有runat="server" ,这对于页面来说是不可能的。

I use asp Texboxes: 我使用asp Texboxes:

<asp:TextBox class="text-input" ID="txtLoginEmail" runat="server"
Height="15px" Width="130px"></asp:TextBox>

and asp Buttons: 和asp按钮:

<asp:Button class="submit google-button" ID="btnLogin" onclick="btnLogin_Click" 

runat="server" Text="Log in" />

except my Search button which is linkButton: 除了我的搜索按钮,它是linkBut​​ton:

<asp:LinkButton ID="searchLink" runat="server" onclick="searchLink_Click">Search</asp:LinkButton>

You may use Validation Groups to cause only required text boxes validation on specific button click. 您可以使用验证组仅在特定按钮单击时导致必需的文本框验证。 And then in event handler to concrete button you may execute specific logic. 然后在事件处理程序到具体按钮中,您可以执行特定的逻辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM