开发者

How to add a new line into Display Attribute, Name field

开发者 https://www.devze.com 2023-03-24 10:50 出处:网络
I\'m working on an MVC3 application and am using data attributes for the display name fields on the screen.Below is a representative sample -

I'm working on an MVC3 application and am using data attributes for the display name fields on the screen. Below is a representative sample -

    [Required]
    [Display(Name = "Staff Id (format \"9999\")")]
    [StringLength(10)]
    [UIHint("StaffId")]
    public string StaffId { get; set; }

What I would like to do is to have the name display on two lines with line break right after "Id" text. So it would display as

   Staff Id
   (format "9999")

Is the开发者_如何学JAVAre a way to do this?


[Required]
[Display(Name = "Staff Id<br/>(format \"9999\")")]
[StringLength(10)]
[UIHint("StaffId")]
public string StaffId { get; set; }

and inside your StaffId.cshtml custom editor template:

@model string
@Html.Raw(ViewData.ModelMetadata.DisplayName)
@Html.TextBox("")


Just adding to @Darin-Dimitrov answer, it is important to use

@Html.Raw(your.property)

Instead of typical HTML helpers like

@Html.DisplayFor(modelItem=>item.property) -- will not work
0

精彩评论

暂无评论...
验证码 换一张
取 消