我正在创建购物网站所以在管理员方面,我正在添加add_product.aspx网页表单,但我收到此错误“类型'TextBox'的控件'c1_t1'必须放在带有runat = server的表单标记内。”产品页面html如下所示,它也有母版页..
<%@ Page Title="" Language="C#" MasterPageFile="~/admin/admin.master" AutoEventWireup="true" CodeFile="add_product.aspx.cs" Inherits="admin_add_product" %>
<asp:Content ID="Content1" ContentPlaceHolderID="c1" Runat="Server">
<h3>Add Product Page</h3>
<table>
<tr>
<td>Product Name</td>
<td>
<asp:TextBox ID="t1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>Product Description</td>
<td>
<asp:TextBox ID="t2" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>Product Price</td>
<td>
<asp:TextBox ID="t3" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>Product Qty</td>
<td>
<asp:TextBox ID="t4" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>Product Image</td>
<td>
<asp:FileUpload ID="FileUploadImageUploader" runat="server" />
</td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick="btnUpload_Click" />
</td>
</tr>
</table>
</asp:Content>
它还有Master Page,我在下面添加母版页代码
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="admin.master.cs" Inherits="admin_admin" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Simple Responsive Admin</title>
<!-- BOOTSTRAP STYLES-->
<link href="assets/css/bootstrap.css" rel="stylesheet" />
<!-- FONTAWESOME STYLES-->
<link href="assets/css/font-awesome.css" rel="stylesheet" />
<!-- CUSTOM STYLES-->
<link href="assets/css/custom.css" rel="stylesheet" />
<!-- GOOGLE FONTS-->
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css' />
</head>
<body>
<form>
<div id="wrapper">
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="adjust-nav">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">
<img src="assets/img/logo.png" />
</a>
</div>
<span class="logout-spn">
<a href="#" style="color: #fff;">LOGOUT</a>
</span>
</div>
</div>
<!-- /. NAV TOP -->
<nav class="navbar-default navbar-side" role="navigation">
<div class="sidebar-collapse">
<ul class="nav" id="main-menu">
<li class="active-link">
<a href="index.html"><i class="fa fa-desktop "></i>Dashboard <span class="badge">Included</span></a>
</li>
<li>
<a href="ui.html"><i class="fa fa-table "></i>UI Elements <span class="badge">Included</span></a>
</li>
<li>
<a href="blank.html"><i class="fa fa-edit "></i>Blank Page <span class="badge">Included</span></a>
</li>
<li>
<a href="#"><i class="fa fa-qrcode "></i>My Link One</a>
</li>
<li>
<a href="#"><i class="fa fa-bar-chart-o"></i>My Link Two</a>
</li>
<li>
<a href="#"><i class="fa fa-edit "></i>My Link Three </a>
</li>
<li>
<a href="#"><i class="fa fa-table "></i>My Link Four</a>
</li>
<li>
<a href="#"><i class="fa fa-edit "></i>My Link Five </a>
</li>
</ul>
</div>
</nav>
<!-- /. NAV SIDE -->
<div id="page-wrapper">
<div id="page-inner">
<div class="row">
<div class="col-lg-12">
<h2>ADMIN DASHBOARD</h2>
</div>
</div>
<!-- /. ROW -->
<hr />
<!-- /. ROW -->
<!--This is content area -->
<asp:ContentPlaceHolder ID="c1" runat="server">
</asp:ContentPlaceHolder>
</div>
</div>
<!-- /. ROW -->
<div class="row">
<div class="col-lg-12 ">
<br />
<div class="alert alert-danger">
<strong>Want More Icons Free ? </strong>Checkout fontawesome website and use any icon <a target="_blank" href="http://fortawesome.github.io/Font-Awesome/icons/">Click Here</a>.
</div>
</div>
</div>
<!-- /. ROW -->
</div>
<div class="footer">
<div class="row">
<div class="col-lg-12">
© 2014 yourdomain.com | Design by: <a href="http://binarytheme.com" style="color: #fff;" target="_blank">www.binarytheme.com</a>
</div>
</div>
</div>
<!-- /. WRAPPER -->
<!-- SCRIPTS -AT THE BOTOM TO REDUCE THE LOAD TIME-->
<!-- JQUERY SCRIPTS -->
<script src="assets/js/jquery-1.10.2.js"></script>
<!-- BOOTSTRAP SCRIPTS -->
<script src="assets/js/bootstrap.min.js"></script>
<!-- CUSTOM SCRIPTS -->
<script src="assets/js/custom.js"></script>
</form>
</body>
</html>
答案 0 :(得分:0)
如错误所述:
&#34;控制&#39; c1_t1&#39;类型&#39; TextBox&#39;必须放在带有runat = server的表单标记内。&#34;
您的表单元素是:
<form>
错误告诉你想做。表单元素需要runat="server"
:
<form runat="server">