Asp.Net MVC Dynamic Model Binding Prefix -
is there way of changing binding prefix value comes request parameters?
i have many nested search popups, , of them shares same viewmodel.
i can add binding prefix fields when requesting search filters, don't know how can make [bind(prefix = "")] work values coming request parameters.
// search filters bindingprefix need public actionresult search(string bindingprefix) { viewdata.templateinfo.htmlfieldprefix = bindingprefix; searchviewmodel model = new searchviewmodel { bindingprefix = bindingprefix }; return partialview("_searchfilters", model); } // post search filters values [httppost] public actionresult search([bind(prefix = model.bindingprefix)]searchviewmodel model) { }
i don't know why want this, should work.
in form on view, have hidden value
@html.hidden("bindingprefix", model.bindingprefix)
modify action following
[httppost] public actionresult search(searchviewmodel model) { updatemodel(model, model.bindingprefix); }
Comments
Post a Comment