是只能有一个。
但可以有多个不是 runat=server的FORM。

解决方案 »

  1.   

    首先,其它web控件必须包含在<form runat="server">中,每次post,server都要检查所有控件状态
    当一个web控件的事件被触发后,server端会在页面post过来的数据中查找对应控件的状态,而Form控件的状态也是server端必须读取的。2个Form控件会造成server无法检查所有控件状态
    所以当然不能存在2个或者2个以上的Form控件了。
      

  2.   

    mg_chen(白沙沙水) 
    你试的可能有问题吧?
    虽然我没有试,但是我想你不同form里面的PageIndexChanged所对应的事件是不是一样啦?分页的问题出在哪里啊?求慎解呦;))))再试一下!期待
      

  3.   

    只能有一个runat="server"标记的form
      

  4.   

    用户控件里面如果有webform,并且是server的,一定不能用了。
    一个页面上不可以有两个server的webform。
    (通过测试的)
      

  5.   

    ASP.NET Doesn't support multiple runat=server forms on the same page.  To handle this problem, you can place each form in a seperate panel control, then allow the user to easilly switch between the panels by clicking on a radio button.
    2FormExample.aspx<%@ Page language="c#" Codebehind="2FormExample.cs" AutoEventWireup="false" Inherits="_3leaf_app.C2FormExample" %>
    <html><head>
    <meta name=vs_targetSchema content="HTML 4.0">
    <meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
    <meta name="CODE_LANGUAGE" Content="C#"></head>
    <body><form method="post" runat="server" ID=Form1>
        <p>Lookup by 
        <asp:RadioButton id=RadioButton1 runat="server" Text="First Name" AutoPostBack="True"  groupname=g1 checked=True></asp:RadioButton>
        <asp:RadioButton id=RadioButton2 runat="server" Text="Last Name" AutoPostBack="True" groupname=g1></asp:RadioButton></p>
        <p></p>
        <p>
        <asp:Panel id=Panel1 runat="server" visible=True>
            First Name : 
            <asp:TextBox id=TextBox1 runat="server"></asp:TextBox>
            <asp:RequiredFieldValidator id=RequiredFieldValidator1 runat="server" ErrorMessage="*" ControlToValidate="TextBox1"></asp:RequiredFieldValidator>
            <asp:Button id=Button1 runat="server" Text="Submit"></asp:Button>
        </asp:Panel>
        <asp:Panel id=Panel2 runat="server" visible=False>
            Last Name : 
            <asp:TextBox id=TextBox2 runat="server"></asp:TextBox>
            <asp:RequiredFieldValidator id=RequiredFieldValidator2 runat="server" ErrorMessage="*" ControlToValidate="TextBox2"></asp:RequiredFieldValidator>
            <asp:Button id=Button2 runat="server" Text="Submit"></asp:Button>
        </asp:Panel>
        <p></p>
        <p>
            <asp:label id=Label1 runat="server"></asp:label>
        </p>
    </form> </body></html>
    2FormExample.csnamespace _3leaf_app
    {
        using System;
        using System.Collections;
        using System.ComponentModel;
        using System.Data;
        using System.Drawing;
        using System.Web;
        using System.Web.SessionState;
        using System.Web.UI;
        using System.Web.UI.WebControls;
        using System.Web.UI.HtmlControls;    /// <summary>
        ///    Summary Description for C2FormExample.
        /// </summary>
        public class C2FormExample : System.Web.UI.Page
        {
      protected System.Web.UI.WebControls.Button Button2;
      protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2;
      protected System.Web.UI.WebControls.TextBox TextBox2;
      protected System.Web.UI.WebControls.Button Button1;
      protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
      protected System.Web.UI.WebControls.TextBox TextBox1;
      protected System.Web.UI.WebControls.Label Label1;
      protected System.Web.UI.WebControls.Panel Panel2;
      protected System.Web.UI.WebControls.Panel Panel1;
      protected System.Web.UI.WebControls.RadioButton RadioButton2;
      protected System.Web.UI.WebControls.RadioButton RadioButton1;
        
        public C2FormExample()
        {
            Page.Init += new System.EventHandler(Page_Init);
            }        protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                }
            }        protected void Page_Init(object sender, EventArgs e)
            {
                //
                // CODEGEN: This call is required by the ASP+ Windows Form Designer.
                //
                InitializeComponent();
            }        /// <summary>
            ///    Required method for Designer support - do not modify
            ///    the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
      {
       RadioButton1.CheckedChanged += new System.EventHandler (this.RadioButton1_CheckedChanged);
       Button1.Click += new System.EventHandler (this.Button1_Click);
       RadioButton2.CheckedChanged += new System.EventHandler (this.RadioButton2_CheckedChanged);
       Button2.Click += new System.EventHandler (this.Button2_Click);
       this.Load += new System.EventHandler (this.Page_Load);
      }        public void Button2_Click (object sender, System.EventArgs e)
            {
                Label1.Text = "You want to search on last name";
            }        public void Button1_Click (object sender, System.EventArgs e)
            {
                Label1.Text = "You want to search on first name";
            }        public void RadioButton2_CheckedChanged (object sender, System.EventArgs e)
            {
                Panel1.Visible = false;
                Panel2.Visible = true;
            }        public void RadioButton1_CheckedChanged (object sender, System.EventArgs e)
            {
                Panel1.Visible = true;
                Panel2.Visible = false;
            }
        }
    }