.aspx
<asp:TextBox ID="txtUser" runat="server" Text="請輸入用戶名"></asp:TextBox>
<br />
<asp:TextBox ID="txtPwd" runat="server" TextMode="Password" ></asp:TextBox>
</div>
.aspx.cs
{
txtUser.Attributes.Add("OnFocus", "if(this.value=='請輸入用戶名') {this.value=''}");
txtUser.Attributes.Add("OnBlur", "if(this.value==''){this.value='請輸入用戶名'}");
txtPwd.Attributes.Add("Value", "請輸入密碼");
txtPwd.Attributes.Add("OnFocus", "if(this.value=='請輸入密碼'){this.value=''}");
}
{value='請輸入用戶名'}"/>
<br/>
<input type="password" value="請輸入密碼" onfocus="if(value=='請輸入密碼') {value=''}"
onBlur="if(value=='') {value='請輸入密碼'}"/>