谁能帮我找出为什么这不起作用:
模型:
public class CreateAdCategoryViewModel
{
[Display(ResourceType = typeof(HeelpResources), Name = "AdViewModel_Category_Label")]
[Required(ErrorMessageResourceName = "AdViewModel_Required_ErrorMsg", ErrorMessageResourceType = typeof(HeelpResources))]
public int Category_Id { get; set; }
public IEnumerable<SelectListItem> CategoryList { get; set; }
public CreateAdCategoryViewModel(IEnumerable<SelectListItem> categoryList)
{
CategoryList = categoryList;
}
}
控制器:
[Authorize]
[HttpPost]
public virtual PartialViewResult CreateAdCategoryType(CreateAdCategoryViewModel model)
{
// Build the ViewModel to return to the View with the Category Drop List
return PartialView(new CreateAdCategoryTypeViewModel(CategoryDropDownList()));
}
看法:
@model Heelp.ViewModels.CreateAdCategoryViewModel
@using (Ajax.BeginForm(MVC.Ad.CreateAdCategoryType(), new AjaxOptions { UpdateTargetId = "category_type", InsertionMode = InsertionMode.Replace }, new { @id = "categoryForm" }))
{
@Html.DisplayNameFor(m => m.Category_Id)
@Html.DropDownListFor(m => m.Category_Id, Model.CategoryList, HeelpResources.DropdownlistCategoryFirstRecord)
@Html.ValidationMessageFor(m => m.Category_Id)
}
提交是由 Javascript 进行的:
$(document).ready(function ()
{
$("#Category_Id").change(function ()
{
$("#categoryForm").submit();
});
});
这里的问题是提交永远找不到CreateAdCategoryType
以模式为参数的动作,为什么?