0

If I don't know what htmlhelper I want to use during design time.., Then is it appropiate to try to new up an htmlhelper from within the controller once I understand which model I will be using? So can I make from a controller an htmlhelper and add it to a view later that was not marked up to use the model? Like a data driven application? If so is there an example of doing so?

1 Answer 1

2

No.

HtmlHelper are extension methods of the MVC.ViewPage and MVC.ViewPage. They cannot be changed inside of a controller.

What you could do is pass a boolean, string, or whatever into your Views and then change the helper based on that.

<% if( Model.IsSomething ) { %>
      <%= Html.MyMagicMethod() %>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.