Rakesh Rakesh - 1 month ago 10
ASP.NET (C#) Question

Control 'c1_t1' of type TextBox must be placed inside a form tag with runat=server in Asp.Net

I am creating shopping website so on admin side i am adding add_product.aspx web form but i am getting this error "Control 'c1_t1' of type 'TextBox' must be placed inside a form tag with runat=server." product page html is given below and it also have master page..

<%@ 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>


it also have Master Page and i am adding master page code below

<%@ 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">
&copy; 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>

Answer Source

As the error states:

"Control 'c1_t1' of type 'TextBox' must be placed inside a form tag with runat=server."

And your form element is:

<form>

The error is telling you want to do. The form element needs runat="server":

<form runat="server">