一个页面只能有一个服务器端的Form标签 [英] A page can have only one server-side Form tag
本文介绍了一个页面只能有一个服务器端的Form标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我添加了一个带有html代码的页面到一个母版页,当我启动页面时我遇到了这个错误。
<%@ Page Title =Language =C#MasterPageFile = 〜/ YourGuruMaster.masterAutoEventWireup =trueCodeFile =YourGuru.aspx.csInherits =YourGuru%>
< asp:Content ID =Content1ContentPlaceHolderID =headRunat =Server>
< style type =text / css>
.style3
{
width:114px;
}
.style4
{
width:293px;
}
.style5
{
width:126px;
}
< / style>
< / asp:Content>
< asp:Content ID =Content2ContentPlaceHolderID =ContentPlaceHolder1Runat =Server>
< form id =form1runat =server>
< div align =center>
< p>
< asp:TextBox ID =Questionrunat =serverstyle =margin-left:0pxWidth =584px>< / asp:TextBox>
< / p>
< / div>
< div align =center>
< table style =width:553px>
< tr>
< td class =style3>
< asp:Button ID =Askrunat =serverText =שאלWidth =50px/>
< / td>
< td class =style4>
< asp:DropDownList ID =DropDownList1runat =server>
< / asp:DropDownList>
& nbsp& nbsp& nbsp
< asp:DropDownList ID =DropDownList2runat =server>
< / asp:DropDownList>
& nbsp& nbsp& nbsp
< asp:DropDownList ID =DropDownList3runat =server>
< / asp:DropDownList>
< / td>
< td class =style5>
< asp:Button ID =Answerrunat =serverText =ענהWidth =50px/>
< / td>
< / tr>
< / table>
< / div>
< / form>
< / asp:Content>
解决方案
ASP.NET Web Forms不会让你把在一个页面中有多个表单
标签 - 您的母版页包含表单
标记,所以:
< asp:Content ID =Content2ContentPlaceHolderID =ContentPlaceHolder1Runat =Server>
< form id =form1runat =server>
< div align =center>
会导致问题,因为它试图添加表单标记。无论如何,您不需要这种形式,因为您的母版页中的表单标签已经足够了。
i added a page with html code to a master page and i got that mistake when i launched the page. i wonder what i did wrong!??!
<%@ Page Title="" Language="C#" MasterPageFile="~/YourGuruMaster.master" AutoEventWireup="true" CodeFile="YourGuru.aspx.cs" Inherits="YourGuru" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<style type="text/css">
.style3
{
width: 114px;
}
.style4
{
width: 293px;
}
.style5
{
width: 126px;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<form id="form1" runat="server">
<div align="center">
<p>
<asp:TextBox ID="Question" runat="server" style="margin-left: 0px" Width="584px"></asp:TextBox>
</p>
</div>
<div align="center">
<table style="width: 553px">
<tr>
<td class="style3">
<asp:Button ID="Ask" runat="server" Text="שאל" Width="50px" />
</td>
<td class="style4">
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
     
<asp:DropDownList ID="DropDownList2" runat="server">
</asp:DropDownList>
     
<asp:DropDownList ID="DropDownList3" runat="server">
</asp:DropDownList>
</td>
<td class="style5">
<asp:Button ID="Answer" runat="server" Text="ענה" Width="50px" />
</td>
</tr>
</table>
</div>
</form>
</asp:Content>
解决方案
ASP.NET Web Forms won't let you put more than one form
tag in a page - your master page contains that form
tag, so this:
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<form id="form1" runat="server">
<div align="center">
will cause problems as it's trying to add a form tag. You don't need this form here anyways as the form tag in your master page is quite adequate.
这篇关于一个页面只能有一个服务器端的Form标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文