asp:TextBox change placeholder via .NET code behind
11,991
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.
Author by
harel486
Updated on August 05, 2022Comments
-
harel486 almost 2 years
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 }