1、aspx页面中的文本框控件
<asp:TextBox ID="textbox1" runat="server">请输入您的用户名</asp:TextBox>2、在相关的cs页面中
protected void Page_Load(object sender, EventArgs e) { textbox1.Attributes.Add("onfocus", "if (this.value=='请输入您的用户名') this.value=''"); textbox1.Attributes.Add("onblur", "if (this.value=='') this.value='请输入您的用户名'"); }注:cs页面中的textbox1为textbox的id,控件id更换,此处id也必须更换,value后面的文字必须与文本框中的文字相同!