型号:
public class BR_Model
{
public string State { get; set; }
[Required]
public DateTime date { get; set; }
public List<SelectListItem> list { get; set; }
}
查看:
<div class="row">
<div class="col-lg-3 col-md-3 col-sm-12">
@Html.DropDownListFor(m => m.State, ViewBag.StateList as IEnumerable<SelectListItem>, new { @class = "form-control input-sm", @onchange = "this.form.submit()" })
</div>
<div class="col-lg-3 col-md-3 col-sm-12">
@Html.ValidationMessageFor(m => m.date)
@Html.TextBoxFor(m => m.date, new { @class = "form-control input-sm", @id = "dp1", @PlaceHolder = "Click Here to Select a Date" })
</div>
</div>
控制器:
DateTime dd = obj.date;
string state = obj.State;
string Date = dd.Date.ToString("yyyy-MM-dd");
我得到的是州的价值而不是约会,它总是01-01-0001 我不知道我在这里做错了什么
日期字段使用bootstarp javascript,没有任何选项
$('#dp1').datepicker( );