📄 mypage.cs
字号:
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
public class myPage : Page {
protected TextBox txtTextBox = new TextBox();
protected Label lblLabel = new Label();
protected override void CreateChildControls() {
// Add Opening HTML Tags
string strOpenHTML;
strOpenHTML = "<html><head><title>My Page</title></head>";
strOpenHTML += "<body>Enter some text:";
Controls.Add(new LiteralControl(strOpenHTML));
// Add HTMLForm Tag
HtmlForm frmForm = new HtmlForm();
frmForm.ID = "myForm";
Controls.Add(frmForm);
// Add a TextBox
txtTextBox.ID = "myTextBox";
frmForm.Controls.Add(txtTextBox);
// Add a Button
Button btnButton = new Button();
btnButton.Text = "Click Here!";
btnButton.Click += new EventHandler(Button_Click);
frmForm.Controls.Add(btnButton);
// Add Page Break
frmForm.Controls.Add(new LiteralControl( "<p>" ));
// Add a Label
lblLabel.ID = "myLabel";
frmForm.Controls.Add(lblLabel);
// Add Closing HTML Tags
string strCloseHTML;
strCloseHTML = "</form></body></html>";
Controls.Add(new LiteralControl(strCloseHTML));
}
void Button_Click(object s, EventArgs e) {
lblLabel.Text = txtTextBox.Text;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -