我的代码如下:
@(Html.Kendo().DropDownList()
.Name("MyDropDownList")
.BindTo(new string[] { "StringOne", "StringTwo", "StringThree"})
.Events(e => e.Change("MyDropDownListOnchange")))
在剧本中:
function MyDropDownListOnchange() {
var val = $("#MyDropDownList").val();
$("#LoadingDiv").load("Views/StringView/_StringOne.cshtml");
我尝试了几种变体:
错误:
//localhost:43222/Views/StringView/_StringOne.cshtml 404 (Not Found)
答案 0 :(得分:1)
尝试这种方式
function change() {
var val = $("#OptionsDrop").val();
//you will have to make a switch case here depending on how many options you have in the DDL
$.ajax({
url: '/StringView/GetStringOne',
dataType: 'html',
success: function (data) {
$('#LoadingDiv').html(data);
}
});
这包括控制器
[HttpGet]
public PartialViewResult GetStringOne()
{
return PartialView("_StringOne");
}
答案 1 :(得分:0)
$("#LoadingDiv").load("Views/StringView/_StringOne.cshtml");
删除.cshtml试试这个:
$("#LoadingDiv").load("Views/StringView/_StringOne");
并确保在您的控制器中返回了此部分视图
类似
[httpget]
public PartialViewResult _StringOne()
{
return PartialView();
}