el shorty
el shorty

Reputation: 237

asp.net call view from a view in another area

So I have a view with a treeview. When you select a node from the treeview, a view should appear next to the treeview. This is easy. You just call the controller from the view and load it into a div like this:

 LoadUserControl('@Url.Action("ViewName", "Controller")', { 'parameter': parameter}, $("#div"));

This works perfectly if the view you are calling is in the same area where you are currently working in. However this doesn't work when it is in another area. When you make the call the controller you are looking for can't be found. Anybody has an idea how to do this?

I'm using asp.net mvc3, c#, jquery and html

Upvotes: 1

Views: 773

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038810

You could specify the area name in the routeValues parameter of the Url.Action helper:

var url = '@Url.Action("SomeAction", "SomeController", new { area = "AreaName" })';
LoadUserControl(url, { 'parameter': parameter}, $('#div'));

Upvotes: 3

Related Questions