页面只能有一个服务器端表单标记错误 [英] A page can have only one server side form tag error

查看:64
本文介绍了页面只能有一个服务器端表单标记错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我是.Net编程的新手,所以请在下面帮助我。



先谢谢。



这是我的默认页面:



 <%@     Page    语言  =  C#    MasterPageFile   = 〜/ Manager.master    AutoEventWireup   =  true    CodeFile   =  MangerComposemessge.aspx.cs    继承  =  MangerComposemessge   标题  =  Untitled Page   %>  


< asp:Content ID = < span class =code-keyword> Content1 ContentPlaceHolderID = head Runat = 服务器 >

< style type = text / css >
style1
{
width 100%;
border 6px solid #FFFFCC;
background-color #FFFFCC;
}
style2
{
width 228px;
}
< / style >

< / asp:Content >
< asp:内容 ID = Content2 runat = 服务器 ContentPlaceHolderID = ContentPlaceHolder1 >
< 表格 id = frm runat = server >

< p >
&
< / p >
< p >
&
< table < span class =code-attribute> class = style1 >
< tr >
< td class = style2 >

< < span class =code-leadattribute> asp:Label ID = Label4 runat = 服务器 文本 = TO > < < span class =code-leadattribute> / asp:Label >
< / td >
< ; td >

& nbsp;& NBSP;&安培; NBSP;&安培; NBSP;&安培; NBSP;&安培; NBSP;&安培; NBSP;

< asp:TextBox ID = TextBox1 runat = server 宽度 = 222px > < / asp:TextBox >
< / td >
< / tr >
< tr >
< td class = style2 >

< asp:标签 ID = Label5 runat = server < span class =code-attribute>文本 = 主题 > < / asp:标签 >
< / td >
< td >

< asp:TextBox ID = TextBox2 runat = server 宽度 = 223px > < / asp:TextBox >
< / td >
< / tr >
< tr >
< ; td class < span class =code-keyword> = style2 >

< asp:标签 ID = Label6 runat = server 文字 = 消息 > < / asp:标签 >
< / td >
< td >
& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& n BSP;&安培; NBSP;
< asp:TextBox ID = TextBox3 runat = 服务器 高度 = 97px TextMode < span class =code-keyword> = MultiLine
< span class =code-attribute>
宽度 = 315px > < / asp:TextBox >
< / td >
< / tr >
< tr >
< td class = style2 >

< asp:Label ID = Label7 runat = server 文字 = 附件 > < / asp:Label >
< / td >
< td >
& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;
< asp:TextBox ID = TextBox4 runat = 服务器 > < / asp:TextBox >
< asp:Button ID = Button2 runat = server 文本 = 浏览 / >
< / td >
< / tr > ;
< tr >
< td class = style2 >
& nbsp; < / td >
< td >
& nbsp; < / td >
< / tr >
< tr >
< ; td class < span class =code-keyword> = sty le2 >
& nbsp; < / td >
< td >
& nbsp ;&安培; NBSP;&安培; NBSP;&安培; NBSP;&安培; NBSP;&安培; NBSP;&安培; NBSP;
< asp:按钮 ID = Button1 runat = 服务器 onclick = Button1_Click 文字 < span class =code-keyword> = 发送 / >
< / td >
< / tr >
< / table >
< br / >
< / p >

< / form >
< / asp:Content >







这是我的主页,我从另一个页面复制了它:



<%@ Master Language = C#AutoEventWireup =trueCodeFile =Manager.master.csInherits =Admin%>



<!DOCTYPE html PUBLIC - // W3C // DTD XHTML 1.0 Transitional // ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">



< html xmlns =http://www.w3.org/1999/xhtml>

< head runat =server>

< title> Untitled Page< / title>

< asp:ContentPlaceHolder id =headrunat =server>



< / head>

< body alink =#ffffcc>

< form id =form1runat =server>







style =font-size:xx-large; font-weight:bold; font-style:normal;颜色:#3399FF; background-color:#FFFFCC;身高:142px;宽度:961px;>











薪资管理系统





< asp:菜单ID =Menu1runat =serverBackColor =#B5C7DE

DynamicHorizo​​ntalOffset =2Font-Bold =TrueFont-Names =Verdana

字体大小=0.8emForeColor =白色高度= 21pxOrientation =Horizo​​ntal

StaticSubMenuInde​​nt =10pxWidth =482px

onmenuitemclick =Menu1_MenuItemClick>

< staticmenustyle backcolor =#0080C0>

< staticselectedstyle backcolor =#507CD1>

< staticmenuitemstyle horizo​​ntalpadding =5pxverticalpadding =2px> ;

< dynamichoverstyle backcolor =#284E98forecolor =White>

< dynamicmenustyle backcolor =#B5C7DE>

< dynami cselectedstyle backcolor =#507CD1>

< dynamicmenuitemstyle horizo​​ntalpadding =5pxverticalpadding =2px>

< statichoverstyle backcolor =#284E98forecolor =白色>

< items>

< asp:MenuItem Text =HomeValue =Home>

< asp:MenuItem Text =EmployeesValue =Employees>

< asp:MenuItem NavigateUrl =〜/ Employee list.aspxText =Employee List

值=员工列表>



< asp:MenuItem Text =MessagesValue =Messages>

< asp:MenuItem Text =Compose MailValue =Compose Mail>

< asp:MenuItem Text =InboxValue =Inbox>

< asp:MenuItem Text =发件箱价值=发件箱>



& lt; asp:MenuItem Text =PayslipValue =Payslip>

< asp:MenuItem Text =Employee PayslipValue =Employee Payslip>

< asp:MenuItem Text =Genrate PayslipValue =Genrate Payslip>



< asp:MenuItem Text =Log OutValue = 退出>








< / form>

< asp:ContentPlaceHolder id =ContentPlaceHolder1runat =server>










< / body>

< / html>

解决方案

您的问题格式不正确。

由于您尝试将表单添加到依赖母版页的内容页面,因此出现此错误。

在母版页中有表单后,您无法将任何其他表单添加到依赖它的单个内容页面中。

即使我们使用母版页和内容页的组合,页面中也只允许一个表单元素。您可以从子页面中删除标记,因为您的母版页已包含表单标记,它将起作用。


Hi,
I am new in .Net programming,so kindly please help me on below.

Thanks in Advance.

This is my Default Page:

<%@ Page Language="C#" MasterPageFile="~/Manager.master" AutoEventWireup="true" CodeFile="MangerComposemessge.aspx.cs" Inherits="MangerComposemessge" Title="Untitled Page" %>


<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

    <style type="text/css">
        .style1
        {
            width: 100%;
            border: 6px solid #FFFFCC;
            background-color: #FFFFCC;
        }
        .style2
        {
            width: 228px;
        }
    </style>

</asp:Content>
<asp:Content ID="Content2" runat="Server" ContentPlaceHolderID="ContentPlaceHolder1" >
<form id="frm" runat="server">

    <p>
        &
    </p>
    <p>
        &
        <table class="style1">
            <tr>
                <td class="style2">
        
        <asp:Label ID="Label4" runat="server" Text="TO"></asp:Label>
                </td>
                <td>

        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

        <asp:TextBox ID="TextBox1" runat="server" Width="222px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="style2">
        
        <asp:Label ID="Label5" runat="server" Text="Subject"></asp:Label>
                </td>
                <td>

 <asp:TextBox ID="TextBox2" runat="server" Width="223px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="style2">
        
        <asp:Label ID="Label6" runat="server" Text="Message"></asp:Label>
                </td>
                <td>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:TextBox ID="TextBox3" runat="server" Height="97px" TextMode="MultiLine"

            Width="315px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="style2">
                    
                    <asp:Label ID="Label7" runat="server" Text="Attachment"></asp:Label>
                </td>
                <td>
       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
       <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
        <asp:Button ID="Button2" runat="server" Text="Browse" />
                </td>
            </tr>
            <tr>
                <td class="style2">
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="style2">
                    &nbsp;</td>
                <td>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Send" />
                </td>
            </tr>
        </table>
        <br />
    </p>

    </form>
</asp:Content>




This is my master page that i copied it from another one:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Manager.master.cs" Inherits="Admin" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<asp:ContentPlaceHolder id="head" runat="server">

</head>
<body alink="#ffffcc">
<form id="form1" runat="server">




style="font-size: xx-large; font-weight: bold; font-style: normal; color: #3399FF; background-color: #FFFFCC; height: 142px; width: 961px;">






Payroll Management System



<asp:Menu ID="Menu1" runat="server" BackColor="#B5C7DE"
DynamicHorizontalOffset="2" Font-Bold="True" Font-Names="Verdana"
Font-Size="0.8em" ForeColor="White" Height="21px" Orientation="Horizontal"
StaticSubMenuIndent="10px" Width="482px"
onmenuitemclick="Menu1_MenuItemClick">
<staticmenustyle backcolor="#0080C0">
<staticselectedstyle backcolor="#507CD1">
<staticmenuitemstyle horizontalpadding="5px" verticalpadding="2px">
<dynamichoverstyle backcolor="#284E98" forecolor="White">
<dynamicmenustyle backcolor="#B5C7DE">
<dynamicselectedstyle backcolor="#507CD1">
<dynamicmenuitemstyle horizontalpadding="5px" verticalpadding="2px">
<statichoverstyle backcolor="#284E98" forecolor="White">
<items>
<asp:MenuItem Text="Home" Value="Home">
<asp:MenuItem Text="Employees" Value="Employees">
<asp:MenuItem NavigateUrl="~/Employee list.aspx" Text="Employee List"
Value="Employee List">

<asp:MenuItem Text="Messages" Value="Messages">
<asp:MenuItem Text="Compose Mail" Value="Compose Mail">
<asp:MenuItem Text="Inbox" Value="Inbox">
<asp:MenuItem Text="Outbox" Value="Outbox">

<asp:MenuItem Text="Payslip" Value="Payslip">
<asp:MenuItem Text="Employee Payslip" Value="Employee Payslip">
<asp:MenuItem Text="Genrate Payslip" Value="Genrate Payslip">

<asp:MenuItem Text="Log Out" Value="Log Out">




</form>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">






</body>
</html>

解决方案

Your question is not well formatted.
This error came up because you tried to add a form to a content page relying on a master page.
Once you have a form in master page you cant add any other form to individual content page relying on it..


Only one form element is allowed in a page even if we are using a combination of master page and content page. You can remove tag from the child page since already your master page contains the form tag and it will work .


这篇关于页面只能有一个服务器端表单标记错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆