<form action="holidayresponse.aspx" method="post">
改成
<form id="form1" method="post" runat="server">服务器端控件必须放在具有 runat=server 的窗体标记内。

解决方案 »

  1.   

    加了runat="server"之后,按submit不能跳转到holidayresponse.aspx了,怎么办?
    必须要跳到holidayresponse.aspx才行
      

  2.   

    you must add "runat=server" into  "<form>"
      

  3.   

    用transfer,请参考下面的列子://////////////////////////////////////////////
    firstpage.aspx
    //////////////////////////////////////////////
    <%@ Page Language="C#" Inherits="FirstPageClass" %><html>
    <head></head><body>   <form runat="server">
          First Name: 
          <asp:TextBox id="first" 
               runat="server"/> 
          <br/>
          Last Name: 
          <asp:TextBox id="last" 
               runat="server"/>
          <br/>
          <asp:Button
               id="Button1" 
               OnClick="ButtonClicked" 
               Text="Go to second page"
               runat=server />
       </form></body></html>
    //////////////////////////////////////////////////
    firstpage.aspx.cs
    //////////////////////////////////////////////
    using System;public class FirstPageClass : System.Web.UI.Page
    {
       protected System.Web.UI.WebControls.TextBox first;
       protected System.Web.UI.WebControls.TextBox last;
       protected System.Web.UI.WebControls.Button Button1;   public string FirstName 
       { 
          get 
          { 
             return first.Text; 
          } 
       }   public string LastName 
       { 
          get 
          { 
             return last.Text; 
          } 
       }   void ButtonClicked(object sender, EventArgs e) 
       { 
          Server.Transfer("secondpage.aspx"); 
       }
    }//////////////////////////////////////////////////
    secondpage.aspx
    //////////////////////////////////////////////////
    <%@ Page Language="C#" Inherits="SecondPageClass" %>
    <%@ Reference Page="firstpage.aspx" %><html><head></head> <body>   <form runat="server">      Hello <%=fp.FirstName%> <%=fp.LastName%>   </form></body></html>
    //////////////////////////////////////////////////
    secondpage.aspx.cs
    //////////////////////////////////////////////////
    using System;public class SecondPageClass : System.Web.UI.Page
    {   protected System.Web.UI.WebControls.Label DisplayLabel;
       public FirstPageClass fp;   void Page_Load() 
       {
          if (!IsPostBack)
          {
             fp = (FirstPageClass) Context.Handler;
          } 
       }}