Specify size and maxlength for Html.TextBoxFor?

Up vote 2 down vote favorite share g+ share fb share tw.

I need to change the size of textbox : @Html. SimpleTextBoxFor(m => ((ModifiableProperty)m).Value. TheCurrentValue, new { id = fieldId}) I tried this @Html.

SimpleTextBoxFor(m => ((ModifiableProperty)m).Value. TheCurrentValue, new { id = fieldId, @maxlength = "100" }) but doesn't work. Asp.

Net-mvc-3 c#-4.0 razor link|improve this question asked Feb 22 at 13:47A. Adnane133.

You can try this too : @Html. SimpleTextBoxFor(m => ((ModifiableProperty)m).Value. TheCurrentValue, new { id = fieldId, style ="width:200px"}) Just change the 200px value for the size you want.

For maxlength I use the same syntax as you and it is working for me. @Html. TextBoxFor(model => model.

EL_Taille_Initiale, new { style = "width:50px", @maxlength = "5" }).

Take out the "@" character for your maxlength attribute. You only need that for reserved keywords (i.e. Class).

Also, you don't need the quotes around the number for maxlength. @Html. SimpleTextBoxFor(m => ((ModifiableProperty)m).Value.

TheCurrentValue, new { id = fieldId, maxlength = 100 }) If that doesn't solve the problem, then please post what the HTML markup is being generated on the response page.

It'doesn't work : – A. Adnane Feb 22 at 14:17 @A. Adnane with a maxlength of 500 you won't have that text truncated.

– Shark Feb 22 at 14:22 – A. Adnane Feb 22 at 14:26 @A. Adnane The problem you're having is because the textbox maxlength will only prevent user input from exceding that value.

But if you are setting the textbox to an initial value that constraint won't limit it. – Shark Feb 22 at 14:30 What I need is this : @Html. SimpleTextBoxFor(m => ((ModifiableProperty)m).Value.

TheCurrentValue, new { id = fieldId, style = "width:"+((ModifiableProperty)Model).Value.TheCurrentValue. Length }) but it doesn't work – A. Adnane Feb 22 at 14:43.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions