是否可以通过后面的 ASP.NET 代码更改文本框 placeholder
?如果是,怎么办?
标记:
<asp:TextBox ID="TXTPassR" runat="server" CssClass="form-control"
placeholder="Enter password" TextMode="Password"></asp:Textbox>
代码隐藏:
if (Something)
{
//Change placeholder
}
最佳答案
使用Attributes.Add()
:
if (Something)
{
TXTPassR.Attributes.Add("placeholder", "Some Text");
}
AttributeCollection.Add Method (String, String): Adds an attribute to a server control's AttributeCollection object.
关于html - asp :TextBox change placeholder via . NET代码隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37348307/