ASP.NET MVC Razor
▌Sample codes
▋@functions
@functions
{
private List<MyData> getData(string id)
{
//....
return something;
}
}
@{
var data = getData("123");
}
|
▋@helper
Always return HelperResult.
@helper
LocaleTitle(string lang, MyData data)
{
if (lang == "EN")
{
@data.TitleEN
}
else if (lang == "CN")
{
<span>简体中文</span>
}
else
{
@Html.Raw("繁體中文")
//@:繁體中文
}
}
<div>
@LocaleTitle("ZH", data)
</div>
|
▌Reference
沒有留言:
張貼留言