0
私はプロパティを持つモデルを持っています。そして、モデルアイテムに値があるかどうかをチェックしたいと思います。また、データアノテーションを使用してプロパティを必須またはオプションに設定しません。プロパティが割り当てられていない場合、それから私は、「一部の検索条件を指定してください。」などいくつかのモデル誤差を設定する必要がありモデルアイテムにMVCの値が割り当てられているかどうかを確認する方法は?
@using (Html.BeginForm("GetAdvanceSearchData", "Home", FormMethod.Post)){
<div class="rTableCell" style="border:none !important">
@Html.TextBoxFor(m => m.MessageStatus, new { placeholder = Html.DisplayNameFor(n => n.MessageStatus), @class = "fieldtextbox", @style = "height: 25px !important" })
@Html.ValidationMessageFor(m => m.MessageStatus)
</div>
<div class="rTableCell" style="border:none !important">
@Html.TextBoxFor(m => m.RequestType, new { placeholder = Html.DisplayNameFor(n => n.RequestType), @class = "fieldtextbox", @style = "height: 25px !important" })
@Html.ValidationMessageFor(m => m.RequestType)
</div>
<div class="rTableCell" style="border:none !important">
</div>
<div class="rTableCell" style="border:none !important">
<p class="submit">
<button type="submit" name="submit">
<i class="fa fa-arrow-right" aria-hidden="true"></i>
</button>
</p>
</div>
}
これらのモデルのための唯一のいくつかのプロパティです。
問題の[MCVE]あなたのコードを追加してください。 – Esko
あなたはそれをクライアントまたはサーバー側で行いたいですか? –