PH控制器
List<PH> publicholidays = new List<PH>();
List<string> PHArray = new List<string>();
for (int row = 1; row <= range.Rows.Count; row++)
{
PH ph = new PH();
ph.Subject = ((MExcel.Range)range.Cells[row, 1]).Text;
ph.StartDate = ((MExcel.Range)range.Cells[row, 2]).Text;
ph.EndDate = ((MExcel.Range)range.Cells[row, 4]).Text;
publicholidays.Add(ph);
PHArray.Add(ph.StartDate);
}
ViewBag.Publicholidays = publicholidays;
PHArray.ToArray();
ViewBag.PHArray = PHArray;
我的PHController中有一个ViewBag.PHArray。如何在属于另一个控制器的视图中访问此数组?在我的另一个控制器中,我使用了datepicker,我希望将数组值用作假日日期:
在离开控制器中创建视图
var array = ["2015-11-25", "2015-11-27", "2015-11-29"]
$('.datepicker').datepicker({
beforeShowDay: function (date) {
var noWeekend = $.datepicker.noWeekends(date);
if (noWeekend[0]) {
return [array.indexOf(jQuery.datepicker.formatDate('yy-mm-dd', date)) == -1]
} else {
return noWeekend;
}
}
});
$(function () { $('#startDate').datepicker({ beforeShowDay: $.datepicker.noWeekends }); });
应使用PH控制器
中的数组替换var array = ["2015-11-25", "2015-11-27", "2015-11-29"]