gpt4 book ai didi

javascript - 如何在 ASP.NET 中使用循环在复选框选择事件上生成另一个表单?

转载 作者:行者123 更新时间:2023-12-03 05:05:04 25 4
gpt4 key购买 nike

我创建了一个带有验证的表单来获取成员(member)的详细信息并进行注册。当用户单击使用它添加另一个成员时,我想创建另一个表单。 ASP.NET 中的一个页面中是否可以有 2 个表单标记,以及如何做到这一点?

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm4.aspx.cs" Inherits="webAss1.WebForm4" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 59%;
}
.auto-style2 {
width: 112px;
}
.auto-style3 {
width: 112px;
height: 29px;
}
.auto-style4 {
height: 29px;
}
</style>
</head>
<body>
<h2>MEMBER REGISTRATION FORM</h2>
<p>
Enter the details:</p>
<form id="form1" runat="server">
<table class="auto-style1">
<tr>
<td class="auto-style2">Name:</td>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
<td>&nbsp;</td>
</tr>
<tr>
<td class="auto-style2">Email:</td>
<td>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</td>
<td>&nbsp;</td>
</tr>
<tr>
<td class="auto-style2">Contact no:</td>
<td>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</td>
<td>&nbsp;</td>
</tr>
<tr>
<td class="auto-style3">Address:</td>
<td class="auto-style4">
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
</td>
<td class="auto-style4"></td>
</tr>
<tr>
<td class="auto-style2">&nbsp;</td>
<td>
<asp:CheckBox ID="CheckBox1" runat="server" />
</td>
<td>&nbsp;</td>
</tr>
<tr>
<td class="auto-style2">&nbsp;</td>
<td>
<asp:Button ID="Button1" runat="server" Text="Button" />
</td>
<td>&nbsp;</td>
</tr>
</table>
<div>

</div>
</form>
</body>
</html>

请帮忙

最佳答案

如果您在页面中测试另一个服务器端表单,您将收到此错误:

A page can have only one server-side Form tag.

但是你可以添加另一个没有 runat="server 的表单。这是一个客户端表单。但我认为它没有用。也许可以为验证提供一些帮助。(当然,客户端验证使用$("#form_id").valid();)

关于javascript - 如何在 ASP.NET 中使用循环在复选框选择事件上生成另一个表单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42041420/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com