Is there a way to get an instance of the Html-Helper within a custom Model-Binder?
Eg:
public class TranslationModelBinder : DefaultModelBinder
{
public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
// HtmlHelper helper = new HtmlHelper(?,?);
object model = base.BindModel(controllerContext, bindingContext);
}
}
How can I get the two needed arguments?
Thx for any tipps! sl3dg3
Even if you could, it would be wrong.
HtmlHelper is a tool for the view where it renders the Model while the binder does the opposite.
The model binder runs much before the view executes so that you don't have a ViewContext
yet which allows you to obtain an HtmlHelper
. You could probably fake this context but that is not something I would recommend you doing. You could have an UrlHelper
though.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.