美好的一天,所有。Html.RenderPartial不会产生值
我知道这是MVC方面的一个非常基本的问题,但我不能为我的生活得到@ Html.RenderPartial不会给我错误。我正在使用VB.NET和Razor。我在网上找到的大多数例子都是用c#编写的,这对我来说不难转换,但是这个简单的例子让我难以置信。这是在我的索引视图,即正由_Layout.vbhtml渲染:
@Section MixPage
@Html.RenderPartial("_MixScreen", ViewData.Model)
End Section
上述表达式不产生的值。
今天早上我已经看过了好一阵子,并且是我采取的例子页面如下:
Getting a Partial View's HTML from inside of the controller
最终,我所要做的是从控制器返回并更新模型到局部视图:
Function UpdateFormulation(model As FormulationModel) As ActionResult
model.GetCalculation()
Return PartialView("_MixScreen", model)
End Function
并且该控制器正在从表达式中调用javascript中:
function UpdateResults() {
jQuery.support.cors = true;
var theUrl = '/Home/UpdateFormulation/';
var formulation = getFormulation();
$.ajax({
type: "POST",
url: theUrl,
contentType: "application/json",
dataType: "json",
data: JSON.stringify(formulation),
success: function (result, textStatus) {
result = jQuery.parseJSON(result.d);
if (result.ErrorMessage == null) {
FillMixScreen(result);
} else {
alert(result.ErrorMessage);
}
},
error: function (xhr, result) {
alert("readyState: " + xhr.readyState + "\nstatus: " + xhr.status);
alert("responseText: " + xhr.responseText);
}
});
}
如果有更好的方式来此更新的模型返回视图,仅更新我所有的耳朵这个局部视图。但是这个问题的前提是:为什么RenderPartial不会产生一个值?
完美!谢谢! – AaronBastian