学习ASP.NET MVC 的Razor的语法,尝试把一段普能的图片链接<a ...><img ... />改为HTML.ActionLink实现。
最原始的代码:
<a href="index.html" class="logo"> <img src="Content/img/logo/logo4-corporation.png" alt="Logo"> </a>
Ok,你可以改为:
<a href="@Url.Action("Index", "Home")" class="logo"> <img src='@Url.Content("~/Content/img/logo/logo4-corporation.png")' /></a>
下面开始尝试改为Html.ActionLink:
@Html.ActionLink(" ", "Index", "Home", null, new{ style = "background: url('" + Url.Content("~/Content/img/logo/logo4-corporation.png") + "') no-repeat center right; display:block; height:84px; width:264px;"})
把样式代码,移至一个css样式文件或是代码块中: