Is it possible to change textbox placeholder
via ASP.NET code behind? If so, how?
Markup:
<asp:TextBox ID="TXTPassR" runat="server" CssClass="form-control"
placeholder="Enter password" TextMode="Password"></asp:Textbox>
Code behind:
if (Something)
{
//Change placeholder
}
Use 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With