我有一个如下定义的模型。
public class Holiday
{
public string Name { get; set; }
public string Description { get; set; }
public DateTime Date { get; set; }
public HolidayType Type { get; set; }
public bool AllYears { get; set; }
}
public enum HolidayType
{
HOLIDAY1 = 1,
HOLIDAY2,
HOLIDAY3
}
在我看来,我正在编写 html 代码而不使用 htmlhelpers(特定项目原因)。现在我的名称、描述、日期等数据被绑定到模型字段,除了单选按钮HolidayType Type
下面是查看代码。如何使用我在页面中的输入自动填充 Type 值。
@model Models.Holiday
@{
ViewBag.Title = "Create";
}
<!DOCTYPE html>
<html>
<head>
<title>Create Holiday</title>
<script src="~/Content/Renderer/KendoUI/kendo.web.min.js"></script>
<script>
$(function () {
$("#holiday").kendoDatePicker();
});
</script>
</head>
<body>
<form id="createholiday" action="/holiday/holiday/create" method="post">
<label for="Name">Holiday Name</label>
<input type="text" id="name" name="Name" /><br />
<label for="Description">Holiday Description</label>
<input type="text" id="description" name="Description" /><br />
<label for="Date" id="date">Date</label><br />
<input id="holiday" name="Date"/><br />
<label for="type">Type</label>
<input type="radio" name="Type" value="Holiday 1">Holiday 1<br>
<input type="radio" name="Type" value="Holiday 2">Holiday 2<br>
<input type="radio" name="Type" value="Holiday 3">Holiday 3<br>
<input type="submit" name="submit" value="Create" />
</form>
</body>
</html>