I have got master page with form (runat="server"). However in nested page, I have 2 forms. First is for changing password and second one is for submiting user data... Both must exist, with separate submit buttons.
我有表格的主页(runat =“server”)。但是在嵌套页面中,我有2个表单。第一个用于更改密码,第二个用于提交用户数据...两者都必须存在,并带有单独的提交按钮。
I tried to enclose appropriate fields with form tags, but I got an error that enclosed forms are not allowed.... How can I achieve my goal?
我试图用表格标签附上相应的字段,但我得到一个错误,不允许附上表格....我怎样才能实现我的目标?
Thanks!
谢谢!
5 个解决方案
#1
4
ASP.NET supports a single form per page only (it emulates desktop sessionful forms). Probably what you need is to leave the form in the master page and to have 2 Click handlers for the buttons on the content page. You may also need to specify ValidationGroup for your controls and buttons so that they don't interfere if you have some validators.
ASP.NET仅支持每页一个表单(它模拟桌面会话表单)。您可能需要的是将表单保留在母版页中,并为内容页面上的按钮提供2个Click处理程序。您可能还需要为控件和按钮指定ValidationGroup,以便在有一些验证器时它们不会产生干扰。
#2
1
As you have already form in master page, you will not be able to add any form in the nested page, there could be only one form tag per page,
由于您已在母版页中形成,因此您将无法在嵌套页面中添加任何表单,每页只能有一个表单标记,
rather than creating two different forms in nested page, cant you create separate two different div, table etc
而不是在嵌套页面中创建两个不同的表单,不能创建单独的两个不同的div,表等
what force you to take form in nested page
是什么迫使你在嵌套页面中采取形式
#3
0
You can have only one < form > tag in ASPX page. When you are using Master page, it already has a < form runat="server "> tag. You can not use < form > tag again in your nested pages. What you can do is add your content on nested page in this tag. < asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server" > < /asp:Content >
ASPX页面中只能有一个
#4
0
You can have multiple form on a webforms page, but only 1 can have the runat-"server' attribute and the runat="server" form cannot have any nested forms. One option that might work for you:
您可以在webforms页面上拥有多个表单,但只有1个表单可以具有runat-“server”属性,而runat =“server”表单不能具有任何嵌套表单。一个可能适合您的选项:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled</title>
</head>
<body>
<div id="header>
<h1>My Site</h1>
<form id="SearchForm" action="search.aspx" method="post">
<!--your search form html inputs (on server controls)-->
</form>
</div>
<!-- the standard webforms form used for server controls etc-->
<form id="form1" runat="server">
<asp:ContentPlaceHolder ID="SearchBody" runat="server">
</asp:ContentPlaceHolder>
</form>
</body>
</html>
You could also look at the PostBackUrl techinique:
您还可以查看PostBackUrl技术:
http://msdn.microsoft.com/en-us/library/ms178140.aspx
http://msdn.microsoft.com/en-us/library/ms178140.aspx
#5
0
Simply add <form runat="server">
at the start of your master page after <body>
tag and inside that put your <asp:content></asp:content>
.
只需在标记之后的母版页开头添加
Ex. MyMasterPage.master page
防爆。 MyMasterPage.master页面
<% master ... %>
<html>
<head> .... </head>
<body>
<form runat="server">
.
.
.
<div>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
</asp:Content>
</div>
.
.
.
</form>
</body>
</html>
Nester Page : MyPage.cs
Nester Page:MyPage.cs
<% page ... %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:Button ID="testButton" runat="server" Text="Sample Button" Width="135px" />
</asp:Content>
In this way you can solve your problem
通过这种方式,您可以解决您的问题
#1
4
ASP.NET supports a single form per page only (it emulates desktop sessionful forms). Probably what you need is to leave the form in the master page and to have 2 Click handlers for the buttons on the content page. You may also need to specify ValidationGroup for your controls and buttons so that they don't interfere if you have some validators.
ASP.NET仅支持每页一个表单(它模拟桌面会话表单)。您可能需要的是将表单保留在母版页中,并为内容页面上的按钮提供2个Click处理程序。您可能还需要为控件和按钮指定ValidationGroup,以便在有一些验证器时它们不会产生干扰。
#2
1
As you have already form in master page, you will not be able to add any form in the nested page, there could be only one form tag per page,
由于您已在母版页中形成,因此您将无法在嵌套页面中添加任何表单,每页只能有一个表单标记,
rather than creating two different forms in nested page, cant you create separate two different div, table etc
而不是在嵌套页面中创建两个不同的表单,不能创建单独的两个不同的div,表等
what force you to take form in nested page
是什么迫使你在嵌套页面中采取形式
#3
0
You can have only one < form > tag in ASPX page. When you are using Master page, it already has a < form runat="server "> tag. You can not use < form > tag again in your nested pages. What you can do is add your content on nested page in this tag. < asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server" > < /asp:Content >
ASPX页面中只能有一个
#4
0
You can have multiple form on a webforms page, but only 1 can have the runat-"server' attribute and the runat="server" form cannot have any nested forms. One option that might work for you:
您可以在webforms页面上拥有多个表单,但只有1个表单可以具有runat-“server”属性,而runat =“server”表单不能具有任何嵌套表单。一个可能适合您的选项:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled</title>
</head>
<body>
<div id="header>
<h1>My Site</h1>
<form id="SearchForm" action="search.aspx" method="post">
<!--your search form html inputs (on server controls)-->
</form>
</div>
<!-- the standard webforms form used for server controls etc-->
<form id="form1" runat="server">
<asp:ContentPlaceHolder ID="SearchBody" runat="server">
</asp:ContentPlaceHolder>
</form>
</body>
</html>
You could also look at the PostBackUrl techinique:
您还可以查看PostBackUrl技术:
http://msdn.microsoft.com/en-us/library/ms178140.aspx
http://msdn.microsoft.com/en-us/library/ms178140.aspx
#5
0
Simply add <form runat="server">
at the start of your master page after <body>
tag and inside that put your <asp:content></asp:content>
.
只需在标记之后的母版页开头添加
Ex. MyMasterPage.master page
防爆。 MyMasterPage.master页面
<% master ... %>
<html>
<head> .... </head>
<body>
<form runat="server">
.
.
.
<div>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
</asp:Content>
</div>
.
.
.
</form>
</body>
</html>
Nester Page : MyPage.cs
Nester Page:MyPage.cs
<% page ... %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:Button ID="testButton" runat="server" Text="Sample Button" Width="135px" />
</asp:Content>
In this way you can solve your problem
通过这种方式,您可以解决您的问题