Asp.net mvc .NETMVC中的验证
单击“插入”按钮时,我需要检查是否已填充所有字段。 我的看法是:Asp.net mvc .NETMVC中的验证,asp.net-mvc,visual-studio,validation,Asp.net Mvc,Visual Studio,Validation,单击“插入”按钮时,我需要检查是否已填充所有字段。 我的看法是: 药物 患者代码ICD10搜索 medicing@Html.DropDownListFor(Model=>Model.medicing,Model.medicing,“选择药物”,新建{style=“宽度:200px;高度:30px”})搜索处方日期 Strength@Html.DropDownListFor(Model=>Model.Strength,Model.Strength,“选择强度”,新{style=“宽度:200
药物
患者代码ICD10搜索
medicing@Html.DropDownListFor(Model=>Model.medicing,Model.medicing,“选择药物”,新建{style=“宽度:200px;高度:30px”})搜索处方日期
Strength@Html.DropDownListFor(Model=>Model.Strength,Model.Strength,“选择强度”,新{style=“宽度:200px;高度:30px”})开始日期结束日期
Form@Html.DropDownListFor(Model=>Model.Form,Model.Form,“选择表单”,新{style=“width:200px;height:30px”})续订日期天数供应
Route@Html.DropDownListFor(Model=>Model.Route,Model.Route,“选择路线”,新建{style=“width:200px;height:30px”})Pharmacy@Html.DropDownListFor(Model=>Model.pharmary,Model.pharmary,“选择药房”,新建{style=“width:200px;height:30px”})
Dose@Html.DropDownListFor(Model=>Model.Dose,Model.Dose,“选择剂量”,新{style=“宽度:200px;高度:30px”})
插入更新删除
您可以使用您的模型进行验证
The best way is adding model Validations in Models
i don't know how your model look like assuming
public class Meditation
{
[Required]
public int id{get;set}
[Required]
public int name{get;set;}
}
using System.ComponentModel.DataAnnotations; should be added
or you can simply use required in form
<input type="text" style="width:85px;height:30px;" name="supply" value="" required>
@Html.DropDownListFor(Model => Model.dosage, Model.dosage, "Select Dose", new { style = "width:200px; height :30px", @required="true"})
最好的方法是在模型中添加模型验证
我不知道你的模型看起来怎么样
公共课冥想
{
[必需]
公共int id{get;set}
[必需]
公共int名称{get;set;}
}
使用System.ComponentModel.DataAnnotations;应该加上
或者您可以简单地在表单中使用required
@DropDownListFor(Model=>Model.Dose,Model.Dose,“选择剂量”,新建{style=“宽度:200px;高度:30px”,@required=“true”})
虽然此链接可以回答问题,但最好在此处包含答案的基本部分,并提供链接供参考。如果链接页面发生更改,则仅链接的答案可能无效。
public class Example {
public int id { get; set; }
[Required]
public string name { get; set; }
}
The best way is adding model Validations in Models
i don't know how your model look like assuming
public class Meditation
{
[Required]
public int id{get;set}
[Required]
public int name{get;set;}
}
using System.ComponentModel.DataAnnotations; should be added
or you can simply use required in form
<input type="text" style="width:85px;height:30px;" name="supply" value="" required>
@Html.DropDownListFor(Model => Model.dosage, Model.dosage, "Select Dose", new { style = "width:200px; height :30px", @required="true"})