Вот общая идея, как бы вы это реализовали.
<script type="text/javascript">
// assuming you're using jQuery
$("#ddlAjax").change( function (event) {
$.ajax({
url: "Controller/GetPartialGraph/" + $(this).val(),
data: { id = $(this).val() /* add other additional parameters */ },
cache: false,
type: "POST",
dataType: "html",
success: function (data, textStatus, XMLHttpRequest) {
$("#divPartialView").html( data ); // HTML DOM replace
}
});
});
</script>
<select id="ddlAjax">
... list of options
</select>
<div id="divPartialView">
<!-- something like this in your ASP.NET View -->
<%= Html.RenderPartial("MyPartialView", Model) %>
</div>
Вот метод действия вашего контроллера.
[HttpPost]
public PartialViewResult GetPartialGraph(int id /* drop down value */)
{
// do calculations whatever you need to do
// instantiate Model object
var model = myBusinessLogicService.DoCalculations(id);
return PartialView("MyPartialView", model);
}
Я думаю, что это ответ, который вы ищете.