摘要:[筆記] ASP.NET TEXTBOX點擊後清空預設值
前端頁面
<div class="inputvalue">
<asp:TextBox ID="adminuser" runat="server" ></asp:TextBox><br />
<asp:TextBox ID="adminpwd" runat="server" ></asp:TextBox>
</div>
後端程式
protected void Page_Load(object sender, EventArgs e)
{
adminuser.Attributes.Add("Value", "帳號");
adminuser.Attributes.Add("onFocus","this.value=''");
adminuser.Attributes.Add("OnBlur", "if(this.value==''){this.value='帳號'}");
adminpwd.Attributes.Add("Value", "密碼");
adminpwd.Attributes.Add("onFocus", "this.value=''");
adminpwd.Attributes.Add("OnBlur", "if(this.value==''){this.value='密碼'}");
}