3

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.

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank You for such a quick reply. It works like wonder. I want to know; it is possible also pass data from one view to another. Like if I want to pass EmployeeID from EmpShifts.aspx to CreateNewShift
@Vabs, yes it is possible. You could use the routeValues parametrer when generating those links. For example: <%= Html.ActionLink("Create new shift", "create", "shift", new { EmployeeID = "123" }, null) %>.

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.