1. 绑定dropdownlist
@{ IEnumerable<SelectListItem> salutationDdlitems = Model.SalutationDdl.Select(s => new SelectListItem { Text = s.DisplayText, Value = s.Value });}
@Html.DropDownListFor(s => s.Feedback.PatSalutation, salutationDdlitems, "[None]", new Dictionary<string, object>() { { "style", "width: 200px;" }, { "id", "patientSal" } })
2. 添加部分视图,相当于Asp.net 中的UserControl
@{Html.RenderPartial("_parName");}
3. ajax form
@{ using (Ajax.BeginForm("FeedBack", "Feedback", new { buttons = "" }, new AjaxOptions() { HttpMethod = "POST", UpdateTargetId = "FeedbackTabContent", OnBegin = "OnBegin", OnComplete = "PostOnComplete", OnSuccess = "ShowPostSuccess", OnFailure = "ShowPostError" }))
{
….
}
4.c# 代码直接输出文本
@if(a=10)
{
@: textcontent
}
输出多行文本
@if(a=10)
{
<text>
content1
content2
</text>
}