Reputation: 13945
I have a little Html Helper called SubTitleWhite, which is used like this:
@Html.SubtitleWhite("hey")
Except instead of "hey" I want to pass something from the ViewBag, which I'm trying to get to work like this:
@Html.SubtitleWhite(@Viewbag.Title)
Except that won't compile:
'System.Web.Mvc.HtmlHelper' has no applicable method named 'SubtitleWhite' but appears to have an extension method by that name. Extension methods cannot be dynamically dispatched. Consider casting the dynamic arguments or calling the extension method without the extension method syntax.
Upvotes: 0
Views: 29
Reputation: 9108
Based on the error message this should work:
@Html.SubtitleWhite((string)Viewbag.Title)
Upvotes: 1
Reputation: 33857
I think you might just need to omit the second @ symbol:
@Html.SubtitleWhite((string)Viewbag.Title)
Updated to correctly cast this viewbag item.
Upvotes: 2