Reputation: 36064
I have a MySmartAnchor method that outputs a Html link. Depending on an object that I pass to MySmartAnchor it will set specific css class and tooltip.
I feel like this is too much logic to put in a View. I don't want to add this method to HtmlHelper methods because it addresses a specific scenario. So I'm thinking of putting this logic inside of a controller and calling it from a View like so @Model.MySmartAnchor(someObject)
Am I on the right track? Should this be done in a View, put inside of a helper method, or controller? I also thought about having a partial but it seems to me it is overkill for a link.
Upvotes: 2
Views: 1075
Reputation: 39501
Seems like good candidate for creating razor helper. If that's only single view specific helper, you should create that into same view that uses it. Else, create helper into App_Code
, for using it across multiple views. Referenced article by ScottGu covers that as well.
Upvotes: 4