我有以下代碼:如果在一行包括HTML語句裏面
<th class="
@if(@Request.QueryString["desc"].AsBool()){ @:table-desc }
@if(@Request.QueryString["desc"].AsBool()){ @:table-desc }
" width="100%" @Html.SortTableClickEvent(@Request.Path, "Name", Convert.ToBoolean(@Request.QueryString["desc"]))>
Name
</th>
它不喜歡的@if語句全部爲在一行中,「@:表說明」認爲,右括號「}」是html的一部分。
任何想法如何解決這個問題?
Parser Error Message: The if block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup.
只是包裹在HTML' '應該工作,而不是'@:'的簡寫。這是不可接受的嗎? –