0

This script works well in MVC 1, however I get "invalid arguments error" in MVC2: this.menuItems.Add("action", Html.ActionLink("action", "view", "Controller"));

1
  • What is the class type of menuitems Commented Nov 10, 2010 at 2:43

1 Answer 1

1

In MVC2, ActionLink returns an MvcHtmlString, and menuItems.Add likely expects a string. So this should work:

this.menuItems.Add("action",
  Html.ActionLink("action", "view", "Controller").ToString());
Sign up to request clarification or add additional context in comments.

7 Comments

Does anyone else find it strange that MvcHtmlString doesn't include an implicit conversion operator for string?
@user373721. No problem. (May I ask that you mark it as the answer. Thanks.)
How can I do that, I searched but did not find an answer, thanks
@Jordan that was a concious decision. Implicit conversion operators can be confusing and we wanted to enforce the difference between encoded and unencoded html strings.
@user373721. It's a checkbox underneath the vote control. No prob if you can't find it.
|

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.