我有一个在视图中生成图像的图表:
<td>
<b>Average Meetings By Day Of Week</b><br />
<img id="imgAvgMeets" src='@Url.Action("GetAvgMeetingsByDayofWeek", "Meeting")' alt="" height="400" width="400" />
</td>
控制器动作:
[HttpGet]
public ActionResult GetAvgMeetingsByDayofWeek()
{
List<TextValuePair> pairs = DataRepository.GetAvgMeetingsByDayofWeek();
var chart = new System.Web.UI.DataVisualization.Charting.Chart();
chart.Width = 300;
chart.Height = 300;
chart.Series.Add(CreateSeries(System.Web.UI.DataVisualization.Charting.SeriesChartType.Bar, pairs));
chart.ChartAreas.Add(CreateChartArea());
System.IO.MemoryStream ms = new System.IO.MemoryStream();
chart.SaveImage(ms);
return File(ms.GetBuffer(), "image/img");
}
这很好用,但是我试图找到一种方法来修改通话中的日期范围,例如:
<td>
<b>Average Meetings By Day Of Week</b><br />
<img id="imgAvgMeets" src='@Url.Action("GetAvgMeetingsByDayofWeek", "Meeting", new { startdate = Model.ChartStartDate, enddate = Model.ChartEndDate })' alt="" height="400" width="400" />
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<table>
<tr>
<td>Start Date:</td>
<td>End Date:</td>
<td>Recalc</td>
</tr>
<tr>
<td><input id="txtStartDate" style="width:50px" /></td>
<td><input id="txtEndDate" style="width:50px" /></td>
<td><button id="btnRecal" type="button" class="displaybutton" onclick="return Recalc();"></button></td>
</tr>
</table>
</td>
</tr>
我可以轻松地修改数据库调用。但是,如何通过参数更改来重新调用该操作?我可以使用日期选择器更改日期范围:
$(“#txtStartDate”)。datepicker({ changeMonth:是的, changeYear:是的, yearRange:“ -0:+1”, maxDate:“ + 1y”, 模态:假, autoClose:是的, onSelect:function(){ $(“#txtEndDate”)。focus(); } });
$("#txtEndDate").datepicker({
changeMonth: true,
changeYear: true,
yearRange: "-1:0",
maxDate: '+1y',
modal: false,
autoClose: true,
onSelect: function () {
$("#btnRecal").focus();
}
});
但是我该如何将它包含在对控制器的新调用中,并在标记中放置一个新图像>