美好的一天,所有。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