![](/img/trans.png)
[英]Curious problem with the ContentPlaceHolder in the HTML Title tag of the masterpage (MVC2)
[英]MVC2 C#: How can I populate a contentplaceholder with html from a file?
所以..我碰上了这个问题是我在迁移客户端的web应用程序MVC2,并显示HTML内容,原来的方法是不能够与MVC所以我需要更新它的工作的。 我需要的功能是这样的:有一个包含操作的侧面导航,并说用户单击“ FooBar”,它将用文档目录中的“ FooBar.html”文件填充“ mainContent”占位符。 如果可能的话,我也希望没有回发。 有任何想法吗?
当用户单击链接时,可以使用jQuery ajax加载页面。 在这里, load()
函数将是理想的。
它只是HTML
和javascript
。 没有特定于ASP.NET MVC的内容
//Include jQuery library
<div>
<a href="Home/about" class="aLink" >About</a>
<a href="Home/FAQ" class="aLink" >FAQ</a>
<a href="Home/Contact" class="aLink" >Contact</a>
</div>
<div id="mainContent">
</div>
<script type="text/javascript">
$(function(){
$("a.aLink").click(function(e){
e.preventDefault(); // prevent the default navigation behaviour
$("#mainContent").load($(this).attr("href"));
});
});
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.