情况:我有一个母版页,它有 3 个内容占位符,但没有表单 runat 服务器。在我的 Login.aspx 中,我尝试填充这些占位符,但它不允许我没有表单 runat 服务器标签,一旦我再次添加多个表单,它会显示:“一个页面只能有一个服务器端表单标签。 "
这是我的代码:
<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="DWDS_Lotus_Care_Final.Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
<form id="formUser" runat="server">
<p>
<asp:Label ID="lblUsername" runat="server" Text="Username"></asp:Label>
<asp:Button ID="btnLogout" runat="server" Text="Logout" />
</p>
</form>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<form id="form1" runat="server">
<table style="width: 100%">
<tr>
<td style="width: 93px">
UserName :
</td>
<td style="width: 139px">
<asp:TextBox ID="txtUserName" runat="server"></asp:TextBox>
</td>
<td style="width: 307px">
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="txtUserName" runat="server" ErrorMessage="*"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td style="width: 93px">
Password :</td>
<td style="width: 139px">
<asp:TextBox ID="txtPassword" runat="server"></asp:TextBox>
</td>
<td style="width: 307px">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="txtPassword" runat="server" ErrorMessage="*"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td style="width: 93px">
</td>
<td style="width: 139px">
<asp:Button ID="btnSubmit" Text="Submit" runat="server"
onclick="btnSubmit_Click" />
<asp:Button ID="btnClear" Text="Clear" runat="server"
onclick="btnClear_Click" />
</td>
<td style="width: 307px">
<asp:LinkButton ID="linkRegister" Text="Register" runat="server"></asp:LinkButton>
</td>
</tr>
</table>
</p>
</form>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder3" runat="server">
</asp:Content>
这是主要来源
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="DWDS_Lotus_Care_Final.Site1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<title>Consistent</title>
<link href="http://fonts.googleapis.com/css?family=Bitter" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div id="wrapper">
<div id="header">
<div id="logo">
</div>
</div>
<div id="menu">
<ul>
<li><a href="#">Login</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Portfolio</a></li>
<li class="last"><a href="#">Contact</a></li>
</ul>
</div>
<div id="page">
<%--Here is the sidebar--%>
<div id="sidebar" style="background-color:#CCCCCC">
<asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server">
</asp:ContentPlaceHolder>
<h3>Links to Other Hospitals</h3>
<div class="date-list">
<ul class="list date-list">
<li class="first"><span class="date">Sunway</span> <a href="#">Sunway Piramid</a></li>
<li><span class="date">KPJ</span> <a href="#">Kajang Care Centre</a></li>
<li><span class="date">HCC</span> <a href="#">Health Care Center</a></li>
<li><span class="date">AlphaH</span> <a href="#">Alpha Health Center</a></li>
<li><span class="date">UPC</span> <a href="#">Bangsar Hospital</a></li>
<li class="last"><span class="date">TPM</span> <a href="#">Technology Park Hospital</a></li>
</ul>
</div>
<br class="clearfix" />
</div>
<%--Here is the Content--%>
<div id="content">
<h2>Welcome to Lotus Care</h2>
<div class="box">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
<div class="box">
<asp:ContentPlaceHolder ID="ContentPlaceHolder3" runat="server">
</asp:ContentPlaceHolder>
</div>
<br class="clearfix" />
</div>
<br class="clearfix" />
</div>
</div>
<div id="footer">
</div>
</body>