嗨即時嘗試從部分視圖或控制器(mvc)在頭部放置鏈接文件,但無法找出或找到任何好的mvc 2示例,任何人都有想法?從部分視圖放置頭文件的css文件
我試圖this評論吉姆Tollan由
它呈現在身體我下面,即時通訊不知道這是什麼好?
<script type='text/javascript'>
$(function(){
$('head').prepend('<link rel="canonical" href="/product/productname/productid"></link>');
});
</script>
我很感激任何幫助,我可以得到這個即時抓我的頭在這個問題上整天現在。
編輯
這是我當前的代碼(這僅僅是樣機代碼複製我的真實的情景)
索引頁
頭內容
<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">
<%: ViewData["Message"] %>
</asp:Content>
體
<div id="container">
empty
</div>
<a href="#" class="click-me">Click me</a>
上
控制器操作
public ActionResult Index()
{
ViewData["Message"] = "this is";
return View();
}
[HttpPost]
public PartialViewResult Index(string value)
{
ViewData["Message"] = "this is not";
return PartialView("_homePartial");
}
jQuery的
$(".click-me").click(function() {
$.post("/Home/Index", function (data) { $('#container').html(data); }, "html");
和多數民衆贊成它,其明顯的可視數據被設置在控制器後的動作,但之後其未設置,這就是爲什麼我需要一個jQuery的解決方案或辦法在頭像視圖中設置頭部內容。 });
任何機會,你可以升級到ASP.Net MVC 3並開始使用Razor與@RenderSection語法? – 2012-03-15 15:17:06
你連接到的stackoverflow問題中的哪個方法你嘗試過? – 2012-03-15 15:18:31
@ShaneCourtrille,這將如何幫助? – 2012-03-15 15:23:02