Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 898
Metaphor Avatar asked Sep 03 '15 05:09

Metaphor


1 Answers

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")
like image 87
Stefano Magistri Avatar answered Nov 07 '22 22:11

Stefano Magistri