ASP.net Contact us

This is a pretty simple question since I'm new to asp.net. I am trying to develop a contact page with us and I get the following error.

"Control 'ContentPlaceHolder1_nameBox' of type 'TextBox' should be placed inside the form tag using runat = server"

Below is my code for this page.

<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="ContactUs.aspx.cs" Inherits="Craigavon_Aquatics.ContactUs" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<h2>
    Contact Us</h2>
<p>
    Please fill in the form below to contact us.</p>

<p>
    &nbsp;</p>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<table style="width: 100%">
    <tr>
        <td>
            Name: (Required)</td>
    </tr>
    <tr>
        <td>
<asp:TextBox ID="nameBox" runat="server" Width="278px"></asp:TextBox>                
        </td>
    </tr>
    <tr>
        <td>
            Email: (Required)</td>
    </tr>
    <tr>
        <td>

        </td>
    </tr>
</table>
</asp:Content>
+3
source share
6 answers

Place a wrapper <form runat="Server">on the main page around the owner of the content, or on this page inside the tag <asp:Content>add <form runat="Server">that will contain your current content.

Site1.Master

<form runat="server">
  <asp:ContentPlaceHolder ...></asp:ContentPlaceHolder>
</form>

-OR -

ContactUs.aspx

<asp:Content ...>
  <form runat="server">
    ...existing HTML code...
  </form>
</asp:Content>
+4
source

ContentPlaceHolder1_nameBox / .aspx, . ASP.Net Server .

0

<form runat="server">// , .. </form>, . , ,

0

, , . , , , .

0

- MasterPage.
.

public override void VerifyRenderingInServerForm(Control control) 
{
    return;
}
0

<form>...</form>, .

This has nothing to do with the β€œcontact page”. This is fundamental to ASP.NET pages in general.

0
source

Source: https://habr.com/ru/post/1791272/


All Articles