开发者

ASP.net MVC, calling a view from different Controller

I have an EmployeeController and ShiftController. In the Index View of EmployeeController I show EmployeeDetails with options of Edit, Delete and GetShifts (this gets all the shifts of that employee 开发者_运维问答- EmpShifts.aspx). In EmpShifts.aspx, I want to give a link to Create New Shift. I want to know how to call Create View of Shifts from EmpShifts.aspx.

Am I having the wrong design structure. Suggestions on that are welcome.


When generating links you can specify the action and controller they are pointing to:

<%= Html.ActionLink("Create new shift", "create", "shift") %>

Same for HTML forms allowing you to POST:

<% using (Html.BeginForm("create", "shift")) <% { %>
    ...
<% } %>

Your design is correct. It is perfectly normal for having links/forms in some view pointing to other controller actions.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜