如何添加一个新行进入显示属性,名称字段 [英] How to add a new line into Display Attribute, Name field

查看:122
本文介绍了如何添加一个新行进入显示属性,名称字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个MVC3应用程序和正在使用的数据属性在屏幕上的显示名称字段。下面是一个重新presentative样本 -

  [必需]
    [显示(名称=员工ID(格式\\9999 \\))
    [StringLength(10)]
    [UIHint(STAFFID)]
    公共字符串{STAFFID获得;组; }

我想这样做是有两条线,断线名称后显示正确的ID的文本。因此,这将显示为

 员工标识
   (格式为9999)

有没有办法做到这一点?


解决方案

  [必需]
[显示(名称=员工ID和LT; BR />(格式\\9999 \\))
[StringLength(10)]
[UIHint(STAFFID)]
公共字符串{STAFFID获得;组; }

和您的 StaffId.cshtml 自定义编辑模板中:

  @model串
@ Html.Raw(ViewData.ModelMetadata.DisplayName)
@ Html.TextBox()

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 there 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("")

这篇关于如何添加一个新行进入显示属性,名称字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆