Search code examples
ajaxasp.net-mvc-3partial-page-refresh

partial view not showing


i have a partial view named "_PartialPage1" under "X" controller. here's the content of my partial view:

<div>Hello</div>

my X controller contains this:

    public ActionResult _PartialPage1()
    {
        return View();
    }

in my home index, i have this:

 <div style="float:left"> @Ajax.ActionLink("Call X", "_PartialPage1", "X", new AjaxOptions() { UpdateTargetId = "divToUpdate" }) </div>
 <div style="float:left"> @Ajax.ActionLink("Call Y", "_PartialPage2", "Y",new  AjaxOptions(){ UpdateTargetId = "divToUpdate" }) </div>
 <div style="float:left"> @Ajax.ActionLink("Call Z", "_PartialPage3", "Z",new  AjaxOptions(){ UpdateTargetId = "divToUpdate" }) </div>

 <div id="divToUpdate"></div>

when i click Call X, nothing is being shown.. i am trying to learn ajax partial page update.... hope you can help me... thanks :)


Solution

  • If you want to render a partial view you should use:

    @Html.Partial("PartialViewName"); 
    

    Where you have a partial view named "PartialViewName" with the div tag hello