Html - Helper in Custom ModelBinder
Is there a way to get an instance of the Html-Helper within a custom Model-Binder?
E.g.:
public class TranslationModelBinder : DefaultModelBinder
{
    public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingCo开发者_运维问答ntext)
    {
       // 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.
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论