开发者

How can I ajax load new pages/views into MainContent when using a master page

Instead of using Html.ActionLink to load subpages into MainContent, I would like to load them with ajax.

For example (taken from Site.Master):

  • <%= Ajax.ActionLink("HOME", "Index", "Home", new AjaxOptions() { UpdateTargetId = "main" })%>
  • 开发者_开发百科
  • <%= Ajax.ActionLink("ABOUT ME", "Index", "About", new AjaxOptions() { UpdateTargetId = "main" })%>
  • <%= Ajax.ActionLink("VIEW MY WORK", "Index", "Work", new AjaxOptions() { UpdateTargetId = "main" })%>
  • <%= Ajax.ActionLink("SERVICES", "Index", "Services", new AjaxOptions() { UpdateTargetId = "main" })%>
  • <%= Ajax.ActionLink("CONTACT", "Index", "Contact", new AjaxOptions() { UpdateTargetId = "main" })%>
  • This works, but when i click one of the links it seems to load the master page all over again.

    http://emma.jabit.se

    Click a link and see what happens. Any ideas how to solve this?


    You must prepare a different view for the index, which does not inherit from the same master page. Remove the MasterPageFile completely, or use a different master page.

    Anyway, this is probably not good design, as you will have problems with the search engines, which will not be able to correctly index your website. Same thing for people who'd like to bookmark or link to an internal page.

    0

    上一篇:

    下一篇:

    精彩评论

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

    最新问答

    问答排行榜