Just a note to myself...
test.cshtml
<!--寫法1-->
<div>
@if (int.Parse(ViewData["score"].ToString()) >= 60)
{
<span>合格!</span>
}
else
{
<span>不合格!</span>
}
</div>
<!--寫法2: 寫成 helper-->
@helper DisplayScore(int score)
{
if (score >= 60)
{
<span>合格!</span>
}
else
{
<span>不合格!</span>
}
}
<div>
@DisplayScore(int.Parse(ViewData["score"].ToString()))
</div>
<!--寫法3: 不同page都要使用它時, 把 helper 寫在App_Code裡-->
@RivaFuns.DisplayScore(int.Parse(ViewData["score"].ToString()))
App_Code > RivaFuns.cshtml
@helper DisplayScore(int score)
{
if (score >= 60)
{
<span>合格!</span>
}
else
{
<span>不合格!</span>
}
}