标签:
1. @Html.Raw() 方法输出带有html标签的字符串:
如: @Html.Raw("<div style=‘color:red‘>Hello World!</div>")
结果:Hello World!
2. @html.ActionLink生成一个<a href=".."></a>标记:
如:@Html.ActionLink(“linkText”、“actionName”、“controlName”,new { id = " 911" },new{ target="_blank"})
结果:<a href = "/controlName/actionName/911">linkText</a>
3. @Url.Action返回一个url
如:@Url.Action(“actionName”、“controlName”,new { id = " 911" })
结果:/controlName/actionName/911
4. @Html.Action加载局部页面,公共部分的代码例如:header/footer/menu/logout...
如:@Html.Action("actionName", "controlName")
用法类似@Html.RenderAction
5. @Html.RenderAction
如:@{ Html.RenderAction("_VSPartial", "CMController");}
_VSPartial内容:
@model ActiveTesting <div> <div> <div> <ul> <li> <div> <a>Hello World!</a> </div> </li> @if (Model != null) { <li><a>Li Li</a></li> } </ul> </div> </div> </div>
原理:根据Controller → Model → View的顺序进行执行,然后把结果进行返回
6. @Html.RenderPartial
将用户控件直接嵌入当前页面
如:@{ Html.RenderPartial("_PatientMRPartial");}
_PatientMRPartial内容:
<div> <div> <div> <h3 class="pull-left">Hello World!</h3> </div> </div> <div> <div> <div> <div> <div> Tom </div> </div> </div> </div> <div class="row cpnmedication-content-line"> <div> <div> <div class="pull-left"> Jim </div> </div> </div> </div> </div> </div>
标签:
原文地址:http://www.cnblogs.com/sccd/p/5580140.html