62-1000 asp.net 頁面回發處理和page物件
阿新 • • 發佈:2021-12-10
10000太遠了,還是近點的用1000,或者100的
後端C#程式碼
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace Asp.NetDemo2 { public partial class DeWebForm1 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) {this.txtNum1.Text = "請輸入內容"; } protected void btnPass_Click(object sender, EventArgs e) { this.txtNum2.Text = this.txtNum1.Text; } } }
前端程式碼
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DeWebForm1.aspx.cs" Inherits="Asp.NetDemo2.DeWebForm1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:TextBox ID="txtNum1" runat="server"></asp:TextBox> <br /> <asp:Button ID="btnPass" runat="server" Text="複製到第二個文字框" onclick="btnPass_Click" /> <br /> <asp:TextBox ID="txtNum2" runat="server"></asp:TextBox> </div> </form> </body> </html>
執行效果: