using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace UserControl { publicpartial class UserControl : System.Web.UI.UserControl { protected void Page_Load(object sender, EventArgs e) { } publicstring txtUserName//属性1:用户名 { set { this.txtName.Text = value; } get { return this.txtName.Text; } } publicstring txtUserPwd//属性2:密码 { set { this.txtPwd.Text = value; } get { return this.txtPwd.Text; } } //控件事件 protected void btnLogin_Click(object sender, EventArgs e) { if((txtUserName == "liuying") && (txtUserPwd =="liuying")) { Response.Write("登陆成功"); } else { Response.Write("登陆失败"); } } } }
原文:http://blog.csdn.net/tgbsqliuying/article/details/40926591