我不想使用 Html.ActionLink 将子页面加载到 MainContent 中,而是使用 ajax 加载它们。
例如(取自Site.Master):
<%= Ajax.ActionLink("HOME", "Index", "Home", new AjaxOptions() { UpdateTargetId = "main" })%>;<%= Ajax.ActionLink("关于我", "索引", "关于", new AjaxOptions() { UpdateTargetId = "main" })%>;<%= Ajax.ActionLink("查看我的工作", "索引", "工作", new AjaxOptions() { UpdateTargetId = "main" })%>;<%= Ajax.ActionLink("SERVICES", "Index", "Services", new AjaxOptions() { UpdateTargetId = "main" })%>;<%= Ajax.ActionLink("CONTACT", "Index", "Contact", new AjaxOptions() { UpdateTargetId = "main" })%>;这是可行的,但是当我单击其中一个链接时,它似乎会再次加载母版页。
http://emma.jabit.se
单击一个链接,看看会发生什么。有什么想法如何解决这个问题吗?
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?
发布评论
评论(1)
您必须为索引准备不同的视图,该视图不继承自同一母版页。完全删除 MasterPageFile,或使用不同的母版页。
无论如何,这可能不是一个好的设计,因为搜索引擎会遇到问题,它将无法正确索引您的网站。对于想要添加书签或链接到内部页面的人来说也是如此。
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.