Vb.net 如何设置MVC Razor视图文本框默认值

Vb.net 如何设置MVC Razor视图文本框默认值,vb.net,razor,asp.net-mvc-5,Vb.net,Razor,Asp.net Mvc 5,当模型值为null/空时,我想在razor视图中设置文本框的默认值。这是我设置默认值的方式,但它当前正在覆盖模型的值,即使它存在: <div class="form-group"> @Html.LabelFor(Function(model) model.PostAction, htmlAttributes:=New With {.class = "control-label col-md-2"}) <div class=

当模型值为null/空时,我想在razor视图中设置文本框的默认值。这是我设置默认值的方式,但它当前正在覆盖模型的值,即使它存在:

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

@LabelFor(Function(model)model.PostAction,htmlAttributes:=New,带有{.class=“control label col-md-2”})
@EditorFor(Function(model)model.PostAction,使用{.htmlAttributes=New和{.Value=“Active”,.class=“form control”}新建)
@Html.ValidationMessageFor(Function(model)model.PostAction,“,新增为{.class=“text danger”})
我希望默认值是一个可选值,仅当模型值为空时设置该值

    <div class="col-md-10">
        @If String.IsNullOrEmpty(Model.PostAction) Then
            @Html.EditorFor(Function(model) model.PostAction, New With {.htmlAttributes = New With {.Value = "Active", .class = "form-control"}})
        Else
            @Html.EditorFor(Function(model) model.PostAction, New With {.htmlAttributes = New With {.class = "form-control"}})
        End If
        @Html.ValidationMessageFor(Function(model) model.PostAction, "", New With {.class = "text-danger"})
    </div>

@如果String.IsNullOrEmpty(Model.PostAction),则
@EditorFor(Function(model)model.PostAction,使用{.htmlAttributes=New和{.Value=“Active”,.class=“form control”}新建)
其他的
@EditorFor(Function(model)model.PostAction,使用{.htmlAttributes=New和{.class=“form control”}新建)
如果结束
@Html.ValidationMessageFor(Function(model)model.PostAction,“,新增为{.class=“text danger”})