Metaphor
Metaphor

Reputation: 374

Specify size and maxlength for Html.Kendo().TextBoxFor

I am using Server Side Validation On ASP.NET MVC Kendo UI. On a view(used to create) for a text field like this:

@Html.Kendo().TextBoxFor(model => model.CompanyTypeName).Name("CompanyTypeName")

I need to change the size of textbox. I tried like this:

@Html.Kendo().TextBoxFor(model => model.CompanyTypeName, new { style = "width:50px", @maxlength = "5" }).Name("CompanyTypeName")

But doesn't work.Thanks in Advance.

Upvotes: 6

Views: 22278

Answers (1)

Stefano Magistri
Stefano Magistri

Reputation: 1160

This is only valid using a default textbox.

@Html.TextBoxFor(model => model.CompanyTypeName, new { style = "width:50px", @maxlength = "5" })

This is what you can do:

@Html.Kendo().TextBoxFor(model => model.CompanyTypeName).HtmlAttributes(new { style = "width:50px", @maxlength = "5" }).Name("CompanyTypeName")

Upvotes: 17

Related Questions