リクエスト パラメータから取得した値でバインディング プレフィックスを変更する方法はありますか?
ネストされた検索ポップアップが多数あり、それらはすべて同じ ViewModel を共有しています。
検索フィルターをリクエストするときにすべてのフィールドにバインド プレフィックスを追加できますが、[Bind(Prefix = "")] をリクエスト パラメーターからの値で動作させる方法がわかりません。
// 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)
{
}