有Runat=Server属性的Form不能提交到别的页面,因为每一个页面的ViewState只能自己才能接受。
但是可以提交普通的Form

解决方案 »

  1.   

    请参考下面的列子://////////////////////////////////////////////
    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;
          } 
       }}
      

  2.   

    <form action="ChangePath.aspx" id="Form1"  method="post">
       <input type="submit" id="mysub" value="提交" >
    </form>去掉其中的runat=server
      

  3.   

    用session也可以的,例如:
    session("txtUsername")=txtUsername.Value
      

  4.   

    another method Design Pattern Using Inline Code:
    //////////////////////////////////////////////
    firstpage.aspx
    //////////////////////////////////////////////
    <%@ Page Language="C#" ClassName="FirstPageClass" %><html>
    <head>
     
       <script runat="server">      public string FirstName 
          { 
             get 
             { 
                return first.Text; 
             } 
          }      public string LastName 
          { 
             get 
             { 
                return last.Text; 
             } 
          }      void ButtonClicked(object sender, EventArgs e) 
          { 
             Server.Transfer("secondpage.aspx"); 
          }   </script> </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 
               OnClick="ButtonClicked" 
               Text="Go to second page"
               runat=server />
       </form></body></html>//////////////////////////////////////////////////
    secondpage.aspx
    //////////////////////////////////////////////////<%@ Page Language="C#" %>
    <%@ Reference Page="firstpage.aspx" %><html><head>
     
       <script runat="server">      FirstPageClass fp;      void Page_Load()
          {
             if (!IsPostBack)
             {
                fp = (FirstPageClass)Context.Handler;
             }
          }
       
       </script></head> <body>   <form runat="server">      Hello <%=fp.FirstName%> <%=fp.LastName%>   </form></body>
    </html>
      

  5.   

    aspx只能提交到本页,要在aspx页面之间切换并传递参数,可以使用response.redirect(***.aspx?arg1=val1)来实现
      

  6.   

    請問上面的例子中fp = (FirstPageClass) Context.Handler;這條語句在vb.net中應該怎麼樣寫,謝謝