Asp.net mvc 如何在MVC中显示编辑器前后的DisplayName标签(英语和阿拉伯语)?

Asp.net mvc 如何在MVC中显示编辑器前后的DisplayName标签(英语和阿拉伯语)?,asp.net-mvc,model,Asp.net Mvc,Model,我想使用MVC(英语和阿拉伯语)创建多语言系统,我想为两种语言使用一个视图,我基于以下模型创建了登录视图: public partial class WEBSITE_USERS { [DisplayName("ID / Iqamam No - رقم الهوية او الاقامة")] [Required(ErrorMessage ="This field is required يجب ادخال رقم الهوية المسجل في

我想使用MVC(英语和阿拉伯语)创建多语言系统,我想为两种语言使用一个视图,我基于以下模型创建了登录视图:

public partial class WEBSITE_USERS
    {

        [DisplayName("ID / Iqamam No   -  رقم الهوية او الاقامة")]
        [Required(ErrorMessage ="This field is required يجب ادخال رقم الهوية المسجل في الملف الطبي ")]
        public string ID_NO { get; set; }

        [DisplayName("Mobile No - رقم الجوال")]
        [Required(ErrorMessage = "Mobile No is required - يجب ادخال رقم الجوال المسجل في الملف ")]
        public string MOBILE { get; set; }

        [DisplayName("Medical Record No - رقم الملف")]
        [Required(ErrorMessage = "File No is required يجب ادخال رقم الملف الطبي ")]
        }
现在DisplayName出现在左侧

如何在编辑器的左侧显示英文标签,右侧显示阿拉伯文标签,如下图所示:

ID/Iqama编号--------------------号

现在其全部显示在左侧,如下所示:

ID/Iqamam编号-第号---------------------------

这是视图代码

@model kaashtaif.Models.WEBSITE_USERS

@{
    ViewBag.Title = "Login Window - شاشة تسجيل الدخول";

}

<h2>Login</h2>


@using (Html.BeginForm("Authorise","Login",FormMethod.Post)) 
{
    @Html.AntiForgeryToken()

<div class="form-horizontal">

    <hr />
    @Html.ValidationSummary(true, "", new { @class = "text-danger" })
    <div class="form-group">
        @Html.LabelFor(model => model.ID_NO, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.ID_NO, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.ID_NO, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.MOBILE, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.MOBILE, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.MOBILE, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.PATIENT_NO, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.PATIENT_NO, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.PATIENT_NO, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="col-md-10">
        <label>@Html.DisplayFor(model => model.LoginErrorMessage)</label>

    </div>

    <div class="form-group">
        <div class="col-md-offset-2 col-md-10">
            <input type="submit" value="Login" class="btn btn-default" />
            <input type="reset" name="name" value="Clear" class="btn btn-default" />
        </div>
    </div>
</div>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
@model kaashtaif.Models.WEBSITE\u用户
@{
ViewBag.Title=“登录窗口-登录”;
}
登录
@使用(Html.BeginForm(“授权”、“登录”、FormMethod.Post))
{
@Html.AntiForgeryToken()

@Html.ValidationSummary(true,“,new{@class=“text danger”}) @LabelFor(model=>model.ID_NO,htmlAttributes:new{@class=“controllabel col-md-2”}) @EditorFor(model=>model.ID_NO,new{htmlAttributes=new{@class=“form control”}}) @Html.ValidationMessageFor(model=>model.ID_NO,“,new{@class=“text danger”}) @LabelFor(model=>model.MOBILE,htmlAttributes:new{@class=“controllabel col-md-2”}) @EditorFor(model=>model.MOBILE,new{htmlAttributes=new{@class=“form control”}) @Html.ValidationMessageFor(model=>model.MOBILE,“,new{@class=“text danger”}) @LabelFor(model=>model.PATIENT_NO,htmlAttributes:new{@class=“controllabel col-md-2”}) @EditorFor(model=>model.PATIENT_NO,new{htmlAttributes=new{@class=“form control”}) @Html.ValidationMessageFor(model=>model.PATIENT_NO,“,new{@class=“text danger”}) @DisplayFor(model=>model.LoginErrorMessage) } @ActionLink(“返回列表”、“索引”) @节脚本{ @Scripts.Render(“~/bundles/jqueryval”) }
这是视图的屏幕截图


最快的方法是更改标记并手动使用
Html.DisplayNameFor()
然后拆分该字符串

对其余的输入字段/表单组重复此过程

<div class="form-group">
        <div class="col-md-3">
           @Html.DisplayNameFor(x => x.ID_NO).ToString().Split('-')[0]
        </div>
        <div class="col-md-6">
            @Html.EditorFor(model => model.ID_NO, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.ID_NO, "", new { @class = "text-danger" })
        </div>
        <div class="col-md-3">
           @Html.DisplayNameFor(x => x.ID_NO).ToString().Split('-')[1]
        </div>
</div>

@Html.DisplayNameFor(x=>x.ID_NO).ToString().Split('-')[0]
@EditorFor(model=>model.ID_NO,new{htmlAttributes=new{@class=“form control”}})
@Html.ValidationMessageFor(model=>model.ID_NO,“,new{@class=“text danger”})
@Html.DisplayNameFor(x=>x.ID_NO).ToString().Split('-')[1]

这里发生的事情是,我们得到了DisplayName属性的值,它是
[DisplayName(“ID/Iqamam-No-friend”)并且因为您有一个分隔符,它是连字符,我们使用
-
或连字符将字符串一分为二,然后按索引显示字符串。

请包含您的视图。@JerdineSabio我添加了视图代码和屏幕截图。非常感谢您的工作,我将为所有字段执行此操作:)