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

前端 未结 2 1401
忘了有多久
忘了有多久 2021-01-25 17:47

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]
           


        
相关标签:
2条回答
  • 2021-01-25 18:21
    [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("")
    
    0 讨论(0)
  • 2021-01-25 18:26

    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 讨论(0)
提交回复
热议问题