Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 控制';MainContent_forenameTxt';类型为';文本框';必须放置在runat=server的表单标记中_C#_Html_Asp.net - Fatal编程技术网

C# 控制';MainContent_forenameTxt';类型为';文本框';必须放置在runat=server的表单标记中

C# 控制';MainContent_forenameTxt';类型为';文本框';必须放置在runat=server的表单标记中,c#,html,asp.net,C#,Html,Asp.net,必须将类型为“TextBox”的控件“MainContent\u forenameTxt”放置在runat=server的表单标记中。[和类似错误] 这个错误已经困扰我好几天了。我已经把问题缩小到主页中的一个问题。 由于某些原因,ASP文本框、按钮等。。要求以某种形式(不一定是这样)但我的程序决定它想要。 因此,当我将表单放入时,这个问题就开始了,指出我只能有一个带有runat=“server”的表单。经过多次谷歌搜索和询问,我得到了以下代码: public override v

必须将类型为“TextBox”的控件“MainContent\u forenameTxt”放置在runat=server的表单标记中。[和类似错误] 这个错误已经困扰我好几天了。我已经把问题缩小到主页中的一个问题。 由于某些原因,ASP文本框、按钮等。。要求以某种形式(不一定是这样)但我的程序决定它想要。 因此,当我将表单放入时,这个问题就开始了,指出我只能有一个带有runat=“server”的表单。经过多次谷歌搜索和询问,我得到了以下代码:

        public override void VerifyRenderingInServerForm(Control Control)
    {
        //base.VerifyRenderingInServerForm(Control);
    }
据我所见,这根本不起作用。它从来没有被调用过,里面什么都没有,但是会使页面显示出来——所以我完全不知道它是做什么的

所以继续下去,它开始困扰我,然后我意识到我的按钮实际上没有做任何事情,除了“刷新”页面。(请参阅靠近页面底部的部分,带有onClicks。)

<%@ Page Title="Registration" Language="C#" AutoEventWireup="true" MasterPageFile="~/MasterPage.Master" CodeFile="registration.aspx.cs" Inherits="registration" %>
仅从这一点来看,我从未看到任何问题(除非其他人能看到)

所以现在,我假设问题在母版页上。我浏览了母版页,将其与我创建的旧网站进行比较,但找不到问题

负责人:


页码.标题
正文:


$(“span.menu”)。单击(函数(){ $(“.top menu ul”)。滑动切换(200); }); 祝大家圣诞快乐 2014年最佳旅游地点 各种优惠 加入德鲁克斯酒店 TBA

TBA

成员区 用户名

密码

现在,作为补充说明

我目前正在为我的网站使用一个引导UI模板。我已经对可能导致问题的代码片段进行了重点介绍

我注意到/尝试过的事情: -母版页上的按钮工作正常。 -“注册”页面上的按钮不起作用(即重置和提交) -注册页面上的参数太大,因此将所有详细信息放在该方法中 -母版页主要内容-在其中放置表单。 -删除所有表单 -创建一个不使用母版页的新测试页(按钮起作用) -与我的其他网站相比

我不是解决问题的专家,我一直在努力寻找这个错误,你很可能会比我发现的更快。 我想为这么大的问题道歉,但我想把这件事整理好,以后不要再重复我的问题了


感谢您查看此内容。

我从未发现问题。但是,在找到足够的替代方案之前,我找到了一个解决方法

我在VisualStudio中启动了一个新项目,并决定挑选出每一条信息,这些信息对于网站看起来仍然相对体面和正常工作来说是绝对必要的

[这意味着,我在contentplaceholder上有一个表单,它包含所有内容,包括另一个contentplaceholder,其中来自其他页面的信息位于该占位符中]

我仍然收到一些错误(很容易修复),但是override类现在没有被使用,因为一些调试发现,我发现它正在重写按钮onClicks

<div class="contact-bg2">
 <div class="container">
     <div class="booking">
         <h3>Register</h3>
         <p>
         </p>
         <div class="col-md-8 booking-form">
             <h5>Forename</h5>
             <asp:TextBox ID="forenameTxt" runat="server"></asp:TextBox>
             <h5>Surname</h5>
             <asp:TextBox ID="surnameTxt" runat="server"></asp:TextBox>
             <h5>Telephone</h5>
             <asp:TextBox ID="telephoneTxt" runat="server"></asp:TextBox>
             <h5>Mobile</h5>
             <asp:TextBox ID="mobileTxt" runat="server"></asp:TextBox>
             <h5>Address</h5>
             <asp:TextBox ID="addressLn1Txt" placeholder="Line 1" runat="server"></asp:TextBox>
             <asp:TextBox ID="addressLn2Txt" placeholder="Line 2" runat="server"></asp:TextBox>
             <asp:TextBox ID="addressLn3Txt" runat="server" placeholder="Line 3"></asp:TextBox>
             <h5>Postal Code</h5>
             <asp:TextBox ID="postalTxt" runat="server"></asp:TextBox>
             <h5>Username</h5>
             <asp:TextBox ID="registerUsernameTxtbox" runat="server"></asp:TextBox>
             <h5>Password Confirm Password</h5>
             <asp:TextBox ID="registerPasswordTxtbox" runat="server" type="password"></asp:TextBox>&nbsp;&nbsp;
              <asp:TextBox ID="passwordConfirmTxt" runat="server" type="password"></asp:TextBox>
             <h5></h5>
             <asp:Button ID="submitBtn" runat="server" Text="SUBMIT" OnClick="submitBtn_Click" />
             <asp:Button ID="resetBtn" runat="server" Text="RESET" OnClick="resetBtn_Click" />
     </div>
         </div>
     </div>
    </asp:Content>
        protected void submitBtn_Click(object sender, EventArgs e)
    {


            //If there is any blank fields, these if statements will be run.
            try
            {
                //If the fields entered have all had an input, this if statement will submit it to the database.
                if (forenameTxt.Text != "" && surnameTxt.Text != "" && telephoneTxt.Text != "" && addressLn1Txt.Text != "" && addressLn2Txt.Text != "" && postalTxt.Text != "" && registerUsernameTxtbox.Text != "" && registerPasswordTxtbox.Text != "" && passwordConfirmTxt.Text != "")
                {

                    DLQueries reposit = new DLQueries();

                    //Refers to 'addCustomerAccount' in droversLodgeRepository 
                    reposit.addCustomerAccount(registerUsernameTxtbox.Text.ToString(),
                      registerPasswordTxtbox.Text.ToString(), forenameTxt.Text.ToString(),
                     surnameTxt.Text.ToString(), mobileTxt.Text.ToString(), telephoneTxt.Text.ToString(),
                        addressLn1Txt.Text.ToString(), addressLn2Txt.Text.ToString(),
                        addressLn3Txt.Text.ToString(), postalTxt.Text.ToString());

                    //Redirects to homepage

                }
                else
                {
                    Response.Redirect("homepage.aspx");
                }

            }

            catch (Exception)
            {
            }

    }
    protected void resetBtn_Click(object sender, EventArgs e)
    {
                    forenameTxt.Text = "";
                    surnameTxt.Text = "";
                    telephoneTxt.Text = ""; 
                    addressLn1Txt.Text = "";
                    addressLn2Txt.Text = "";
                    postalTxt.Text = "";
                    registerUsernameTxtbox.Text = ""; 
                    registerPasswordTxtbox.Text = "";
                    passwordConfirmTxt.Text = "";
    }
 <head id="Head1" runat="server">
<title>Page.Title</title>
<link href='http://fonts.googleapis.com/css?family=Open+Sans:600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Pinyon+Script' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Quicksand:400,700' rel='stylesheet' type='text/css'>
 <link href="css/bootstrap.css" rel='stylesheet' type='text/css'/>
<link href="css/style.css" rel="stylesheet" type="text/css" media="all"/>

<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="js/jquery.min.js"></script>
</head>
    <body>
    <div class="header">
     <div class="top-header">
         <div class="container">
             <div class="logo">
                    <a href="index.html"><img src="images/logo.png"/></a>
             </div>
             <span class="menu"> </span>
             <div class="m-clear"></div>
             <div class="top-menu">
                <ul>
                     <li class="scroll"><a href="homepage.aspx">HOME</a></li>
                     <li><a class="scroll" href="facilities.aspx">FACILITIES</a></li>
                    <li><a class="scroll" href="pricing.aspx">PRICS</a></li>
                     <li><a class="scroll" href="contactUs.aspx">CONTACT US</a></li>
                </ul>
                <script>
                    $("span.menu").click(function () {
                        $(".top-menu ul").slideToggle(200);
                    });
                </script>
             </div>
             <div class="clearfix"></div>
          </div>
      </div>
</div>


        <div id="body">
        <asp:ContentPlaceHolder runat="server" ID="FeaturedContent" />
        <section class="content-wrapper main-content clear-fix"> 
            <asp:ContentPlaceHolder runat="server" ID="MainContent" >
                </asp:ContentPlaceHolder>
        </section>
    </div>
    </>

    <!---->
    <div class="fotter">
        <div class="container">
            <h3>143 City Located Hotels World Wide</h3>
            <h4>"Hospitality, Quality & Good Locations. We only provide you with the best hotels" - John Deo</h4>
            <i class="man"></i>
        </div>
    </div>
    <!---->

    <div class="fotter-info">
        <div class="container">
            <div class="col-md-5 details">
                <div class="hotel-info">
                    <h4>ABOUT THIS HOTEL</h4>
                    <p>This hotel is a 4 Star Hotel found on the Isle of Mull, in Scotland. </p>
                    <p><b>In order to book for this hotel, you will require to create an account online!</b></p>
                </div>
                <div class="news">
                    <h4>LATEST NEWS</h4>
                    <h5>Grand Hotel Joins DeluxelHotels</h5>
                    <a href="#">15 AUG</a>
                    <h5>Happy Chirstmas To Everyone</h5>
                    <a href="#">15 AUG</a>
                    <h5>Best Places To Visit 2014</h5>
                    <a href="#">15 AUG</a>
                    <h5>Various Offers</h5>
                    <a href="#">15 AUG</a>
                </div>
                <div class="clearfix"></div>
            </div>
            <div class="col-md-7 details">
                <div class="join">
                    <h4>JOIN DELUXEHOTELS</h4>
                    <p>
                        TBA
                    </p>
                    <p>TBA</p>
                    <a href="aboutUs.aspx">READ MORE</a>
                </div>
                <div class="member">
                    <h4>MEMBERS AREA</h4>
                    <form id="Form1" runat="server">
                        <p>Username</p>
                        <asp:textbox id="txtUsername" runat="server"></asp:textbox>
                        <p>Password</p>
                        <asp:textbox id="txtPassword" textmode="Password" runat="server" />
                        <asp:button id="logoutBtn" runat="server" text="LOGOUT" visible="false" onclick="logoutBtn_Click" />
                        <asp:button id="loginBtn" runat="server" text="LOGIN" onclick="loginBtn_Click" />
                        &nbsp;&nbsp;&nbsp;&nbsp; 
                     <asp:button id="registerBtn" runat="server" text="REGISTER" onclick="registerBtn_Click" />
                   </form>
                </div>
                <div class="clearfix"></div>
            </div>
            <div class="clearfix"></div>
        </div>
    </div>
        </body>