PDA

Click to See Complete Forum and Search --> : VS 2010 [RESOLVED] MetaData Formatting MVC 3


Bill Crawley
Jun 10th, 2011, 05:44 AM
Hi All,

I'm using POCO entities and am using MetaData to help with the UI.

This works ok, but seems to default the display. e.g.

[DisplayName("")]
[UIHint("NotEnabledForDecimal")]
public object TechnicalPriceRo { get; set; }

This gives me a an uneditable textbox with the value of the object (Good).
However, I want to reduce the width of the textbox and the contents are left aligned when I want them right aligned. Does anybody have any idea what I need to attach to my MetaData to make these 2 things happen?

Thanks

Bill Crawley
Jun 10th, 2011, 08:13 AM
Update...Still not working, but in my NotEnabledForDecimal Helper, I thought the size property would do the trick regarding size of the box, but it's made no difference:

@model Decimal
@Html.TextBox("", Model.ToString(), new { disabled = "disabled", size = 4 })

To align the text to the right, I thought I'd be able to use the inline-styling:

<div style="width:10em; clear:both; left:308px; position:relative; text-align:right;">
@Html.EditorFor(model => model.TechnicalPriceRo)
</div>

that too doesn't work

Bill Crawley
Jun 10th, 2011, 08:34 AM
Ok, just for completeness, Here is the answer:

the style needs to be set against the helper, then it all works:

@model Decimal
@Html.TextBox("", Model.ToString(), new { disabled = "disabled", style="width:5em; text-align:right" })