Watermark for Textbox in MVC3

前端 未结 4 1214
不知归路
不知归路 2021-01-12 04:38

How do I set watermark for a texbox in MVC3 .Also if there are multiple textboxes in a web page, how do you write different watermark text for each textbox?



        
4条回答
  •  醉话见心
    2021-01-12 05:26

    If I understand your question, you can just pass in:

    new { placeholder = "my watermark" }
    

    as the htmlAttributes parameter in Html.TextBoxFor.

    Edit:

    You can also add support for older browsers by using Javascript as outlined here:

    http://www.standardista.com/html5-placeholder-attribute-script

提交回复
热议问题