Search code examples
asp.net-mvckendo-uikendo-asp.net-mvc

Password TextBox for Kendo UI MVC


I'm wanting to create a login page using the Telerik Kendo UI Textboxes so I will need my password input masked. Does anyone have any suggestions? I've tried:

                .TextBoxFor(m => m.Password)
                .HtmlAttributes(new { type = "password" })

below is my code as pretty much standard it is:

  @(Html.Kendo().TextBox()
                .Name("password")
                .Placeholder("Password")
                .Label(label => label
                    .Content("Password")
                    .Floating(true)
                )
                .HtmlAttributes(new { style = "width: 100%;border-radius: 7px;border-color: #ff4d41;" })
            )

Getting to the stage I'd be faster just creating my own textboxes lol


Solution

  • as per my understanding based on your question you need to add type="password" in kendo UI control.

    Like below code

     @(Html.Kendo().TextBox()
    .Name("password")
    .Placeholder("Password")
    .Label(label => label
    .Content("Password")
    .Floating(true)
    )
    .HtmlAttributes(new {type="password", style = "width: 100%;border-radius: 7px;border-color: #ff4d41;" })
    )      
    

    Output Image

    As we know Password HTML helper available in MVC.

    @Html.Password()
    @Html.PasswordFor()