• <label id="pxtpz"><meter id="pxtpz"></meter></label>
      1. <span id="pxtpz"><optgroup id="pxtpz"></optgroup></span>

        當(dāng)前位置:雨林木風(fēng)下載站 > 技術(shù)開發(fā)教程 > 詳細(xì)頁面

        ASP.NET中運(yùn)用多個(gè)runat=server form

        ASP.NET中運(yùn)用多個(gè)runat=server form

        更新時(shí)間:2022-05-13 文章作者:未知 信息來源:網(wǎng)絡(luò) 閱讀次數(shù):

        ASP.NET 在同一個(gè)頁面不支持多個(gè) runat=server forms,要解決這個(gè)問題,可以把每個(gè) form 放在一個(gè)單獨(dú)的 panel 控件中,這樣用戶就可以簡單地通過單選按鈕在不同 panel 間切換。
        代碼如下:
        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.cs

        namespace _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;
                }
            }
        }



        溫馨提示:喜歡本站的話,請(qǐng)收藏一下本站!

        本類教程下載

        系統(tǒng)下載排行

        主站蜘蛛池模板: 亚洲精品免费在线观看| 一个人看的在线免费视频| 99久在线国内在线播放免费观看 | 免费人成网上在线观看| 国产成人免费片在线视频观看| 亚洲国产成人久久| 7723日本高清完整版免费| 亚洲精品视频久久| 日本免费xxxx色视频| 亚洲第一香蕉视频| 2020久久精品国产免费| 中文字幕无码亚洲欧洲日韩| 最近中文字幕免费mv视频8| 亚洲熟妇无码一区二区三区| 狼友av永久网站免费观看| 久久久久亚洲精品无码网址色欲| 免费国产一级特黄久久| 一边摸一边桶一边脱免费视频 | 成人av免费电影| 亚洲欧美第一成人网站7777| 免费久久精品国产片香蕉| www免费插插视频| 亚洲国产美女精品久久久久∴| 久久免费视频网站| 亚洲精品美女视频| 四虎成人免费网站在线| 日韩少妇内射免费播放| 亚洲日本在线观看| 成年人网站在线免费观看| 美女黄频免费网站| 亚洲熟女少妇一区二区| xxxx日本免费| 国产精品亚洲精品日韩电影| 国产亚洲精品无码专区| 67194国产精品免费观看| 亚洲Aⅴ在线无码播放毛片一线天| 亚洲国产中文v高清在线观看| 很黄很污的网站免费| 中文字幕无码亚洲欧洲日韩| 亚洲色婷婷综合开心网| h在线观看视频免费网站|