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

        當前位置:雨林木風下載站 > 技術開發教程 > 詳細頁面

        ASP.NET中運用多個runat=server form

        ASP.NET中運用多個runat=server form

        更新時間:2022-05-13 文章作者:未知 信息來源:網絡 閱讀次數:

        ASP.NET 在同一個頁面不支持多個 runat=server forms,要解決這個問題,可以把每個 form 放在一個單獨的 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;
                }
            }
        }



        溫馨提示:喜歡本站的話,請收藏一下本站!

        本類教程下載

        系統下載排行

        主站蜘蛛池模板: 亚洲熟妇av一区| 久久亚洲国产精品成人AV秋霞| 中文字幕在线观看亚洲视频| 亚洲精品视频在线免费| 亚洲第一中文字幕| 日日麻批免费40分钟无码| 日木av无码专区亚洲av毛片| 日韩人妻一区二区三区免费| 中文字幕亚洲第一在线| 永久看日本大片免费35分钟| 亚洲最大黄色网站| 一个人免费观看视频www| 免费av一区二区三区| 亚洲AV福利天堂一区二区三| 99免费在线观看视频| 亚洲一区二区三区在线观看蜜桃 | 亚洲国产乱码最新视频| 日本无吗免费一二区| 色网站在线免费观看| 国产精品亚洲w码日韩中文| 亚洲精品第一国产综合野| 在线视频免费观看高清| 亚洲AV网一区二区三区 | 亚洲一区二区三区四区视频| 毛片免费全部播放一级| 免费无码午夜福利片| 国产v亚洲v天堂无码网站| 91久久精品国产免费直播| 亚洲欧洲国产综合AV无码久久| 国产在线观看免费完整版中文版| 一区二区三区视频免费| 亚洲国产精品久久久久| 成人毛片免费观看视频大全| 四虎成人精品国产永久免费无码| 国产精品亚洲片在线观看不卡| av无码免费一区二区三区| 欧美激情综合亚洲一二区| 亚洲av无码片在线播放| 成人免费视频网址| 国内精品99亚洲免费高清| 在线亚洲午夜片AV大片|