I trying to load a partial view when an actionlink is click. I've attempted it by creating a surface controller however it's linking to the partialview rather than loading the partialview with the page. Creates a link to umbraco/Surface/ControllerName/Index
If you want to control the rendering for a page then you need to use route hijacking.
So say you have an Index page like above:
Create a document type called Index
Create a content page of type Index
Create a controller call IndexController and inherit from RenderMvcController
The the action result is called the same as the template alias
Do you stuff in there and then return view("");
e.g.:
public class IndexController : RenderMvcController
{
/// <summary>
/// Hijack the Index Document Type Rendering
/// </summary>
/// <returns></returns>
public ActionResult IndexTemplateAlias(string querystringval)
{
// Do your stuff
return View();
}
}
Hi Damian thanks for your reply I don't belive it's what I'm after. I'm trying to limit the page size but give the user the option to see a larger page alittle like "more posts" on twitter. I was just trying to get the partial view to display if they clicked on a link. I now attempting to get "Hello" (data) through JSON instead.
Return partial view on with Actionlink
I trying to load a partial view when an actionlink is click. I've attempted it by creating a surface controller however it's linking to the partialview rather than loading the partialview with the page. Creates a link to umbraco/Surface/ControllerName/Index
Main View
Controller
View /ContollerName/Index.cshtml
Hi John,
If you want to control the rendering for a page then you need to use route hijacking.
So say you have an Index page like above:
Create a document type called Index Create a content page of type Index
Create a controller call IndexController and inherit from RenderMvcController
The the action result is called the same as the template alias
Do you stuff in there and then return view("");
e.g.:
Is that what you are after?
Damian
Hi Damian thanks for your reply I don't belive it's what I'm after. I'm trying to limit the page size but give the user the option to see a larger page alittle like "more posts" on twitter. I was just trying to get the partial view to display if they clicked on a link. I now attempting to get "Hello" (data) through JSON instead.
Then your best bet would be an ajax request and you populate a div with the html returned from the partial - so you dont change pages.
At the moment the request is returning the partial as the page which has no master page etc. so thats what you get - just the partial.
Damian
This article is a good example of the request but its using alt templates here.
http://24days.in/umbraco/2012/ajax-paging-using-alttemplates/
Damian
Thanks Damian getting to be along the right lines what I'm after hopefully I can get this to work in MVC :)
Best way to get it to work with MVC and Umbraco is to use an Umbraco Api Controller and return JSON.
This page has some info in it:
http://www.nibble.be/?p=224
Damian
Hi Damian,
Thanks for all your help.
I ended up creating an helper class to get the property
Then a SurfaceContoller
public ActionResult Index()
Hi Damian,
How to connect in the index view the links from the buttons on the index page to another action in the same controller, these ones:
@Html.ActionLink("Edit", "Edit", new { id = item.AnimalID })
@Html.ActionLink("Details", "Details", new { id = item.AnimalID })
@Html.ActionLink("Delete", "Delete", new { id = item.AnimalID })
is working on a reply...