Convert textbox type to password in asp.net mvc

后端 未结 11 2521
感情败类
感情败类 2020-12-18 18:13

How do I convert a textbox type to password in asp.net mvc?

11条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-18 18:17

    Another way is to add @type = password to your html.texbox() attributes like so:

    before converting:

    @Html.TextBox("mypass", null, new { @class = "" })
    

    After converting:

    @Html.TextBox("mypass", null, new { @class = "", @type = password })
    

    This will mask your text box text with circles instead of text. It does this, because the @type = password attribute tells your text box that it is of type "password".

    This method of converting your text box to type password is an easy quick way to to make the conversion from your standard razor form text box.

提交回复
热议问题