Add HTML5 placeholder text to a textbox .net

前端 未结 4 1510
一生所求
一生所求 2020-12-10 10:29

I have a standard input:


I\'d like to have this render with a dyn

4条回答
  •  失恋的感觉
    2020-12-10 11:14

    You could use the Attributes collection. So you would have something like

    txtSearchTerm.Attributes.Add("placeholder", "Search" + Site.Name);
    

    or

    txtSearchTerm.Attributes["placeholder"] = "Search" + Site.Name; // or Attributes("placeholder") if you're using vb.net
    

    And if you're using resources for localization/translation:

    txtSearchTerm.Attributes["placeholder"] = GetLocalResourceObject("YourLocalResourceName").ToString();
    

提交回复
热议问题