3
바인딩 매개 변수를 요청 매개 변수에서 오는 값으로 변경하는 방법이 있습니까?Asp.Net MVC 동적 모델 바인딩 접두사
나는 많은 중첩 된 검색 팝업이 있으며, 모두 동일한 ViewModel을 공유합니다.
검색 필터를 요청할 때 모든 필드에 바인딩 접두어를 추가 할 수 있지만 요청 매개 변수에서 오는 값을 사용하여 [바인딩 (접두사 = "")을 어떻게 만들 수 있는지 모르겠습니다. .
// get the search filters with the bindingPrefix we need
public ActionResult Search(string bindingPrefix)
{
ViewData.TemplateInfo.HtmlFieldPrefix = bindingPrefix;
SearchViewModel model = new SearchViewModel
{
BindingPrefix = bindingPrefix
};
return PartialView("_SearchFilters", model);
}
// post the search filters values
[HttpPost]
public ActionResult Search([Bind(Prefix = model.BindingPrefix)]SearchViewModel model)
{
}
로 수정 작업 숨겨진 값이 왜 당신이 당신의 행동에 바인딩 접두사를 변경하려면 어떻게해야합니까 있나요? – ataravati