开发者

Is passing parameters for controller overload from view good practice in .Net MVC

So right now I have a partial view that just has a list of possible actions, here is the main portion:

<%= Html.ActionLink("Show", "Show", new { id = dbId, css="/Content/Site.css"  })  %> |
<%= Html.ActionLink("Edit", "Edit", new { id = dbId  })  %> |
<%= Html.ActionLink("Delete", "Delete", new { id = dbId }, new { @class = "deleteLink" })%>|
<%= Html.ActionLink("Print", "Show", new { id = dbId, css="/Content/Other.css"}) %>

Essentially, there is a Show and and Print option, I decided it would be more convenient to not create a new view for print, and just overload the Show Action by passing an extra parameter that would tell which CSS to display, and then use ViewData to set the CSS for the view.

Is this good practice? Should I create a new view? They are completely th开发者_运维百科e same except for the CSS.


If the css is the only thing that is different, you could just include the css and set the media type to be picked up when the user prints from the browser, e.g.:

<style media="print" ...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜