📄 textwebpart.cs
字号:
using System;
using System.Security.Permissions;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
namespace AspNet.CS.Controls
{
public class TextWebPart : WebPart
{
private String LabelText = null;
TextBox input;
Label DisplayContent;
public TextWebPart()
{
this.AllowClose = false;
this.LabelText = "姓名:";
}
[Personalizable(), WebBrowsable]
public String ContentText//自定义属性
{
get { return LabelText; }
set { LabelText = value; }
}
//重写控件
protected override void CreateChildControls()
{
Controls.Clear();
DisplayContent = new Label();//实例标签
DisplayContent.BackColor = System.Drawing.Color.LightBlue;//实例标签
DisplayContent.Text = this.ContentText;//给标签Text属性赋值,把自定义属性给标签
this.Controls.Add(DisplayContent);//注册标签控件添
input = new TextBox();//实例文本框
this.Controls.Add(input);//注册文本框
ChildControlsCreated = true;//确认创建WEBPART控件子控件
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -