⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eventbuffer.aspx

📁 asp.net_Lesson4
💻 ASPX
字号:
<html>
    <head>
        <title>事件缓存</title>
        <script Language="C#" runat="server" >
            void Page_Load()
            {
                TextBox1.TextChanged += new EventHandler(onTextBox1);
                TextBox2.TextChanged += new EventHandler(onTextBox2);
                TextBox3.TextChanged += new EventHandler(onTextBox3);
                btnAuto.Click += new EventHandler(onAuto);
                btnNoAuto.Click += new EventHandler(onNoAuto);
                Result.Text = "";

                if(this.IsPostBack == false)
                {
                    TextBox1.AutoPostBack = false;
                    TextBox2.AutoPostBack = false;
                    TextBox3.AutoPostBack = false;
                    Label1.Text = "Not Auto";
                    Label2.Text = "Not Auto";
                    Label3.Text = "Not Auto";
                }
            }

            void onNoAuto(object sender, EventArgs arg)
            {
                TextBox1.AutoPostBack = false;
                TextBox2.AutoPostBack = false;
                TextBox3.AutoPostBack = false;
                Label1.Text = "Not Auto";
                Label2.Text = "Not Auto";
                Label3.Text = "Not Auto";
            }

            void onAuto(object sender, EventArgs arg)
            {
                TextBox1.AutoPostBack = true;
                TextBox2.AutoPostBack = true;
                TextBox3.AutoPostBack = true;
                Label1.Text = "Auto";
                Label2.Text = "Auto";
                Label3.Text = "Auto";
            }

            void onTextBox1(object sender, EventArgs arg)
            {
                Result.Text += "TextBox1<br/>";
            }
            void onTextBox2(object sender, EventArgs arg)
            {
                Result.Text += "TextBox2<br/>";
            }
            void onTextBox3(object sender, EventArgs arg)
            {
                Result.Text += "TextBox3<br/>";
            }
        </script>
    </head>

    <body>
        <form id="form1" method="post" runat="server">
            <asp:TextBox id="TextBox1" runat="server" width="100px" />
            <asp:Label id="Label1" runat="server" width="80px" /></br>
            <asp:TextBox id="TextBox2" runat="server" width="100px" />
            <asp:Label id="Label2" runat="server" width="80px" /></br>
            <asp:TextBox id="TextBox3" runat="server" width="100px" />
            <asp:Label id="Label3" runat="server" width="80px" /></br>
            <hr/>

            <asp:Button id="btnAuto" runat="server" text="AutoPostBack" />
            <asp:Button id="btnNoAuto" runat="server" text="No AutoPostBack" />
            <asp:Button id="Submit" runat="server" text="提交" />
            <br/>

            <asp:Label id="Result" runat="server" /></br>
        </form>
    </body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -