0
想要使用@Html.Raw來顯示Html解碼的字符串。razor html.raw帶數組使用jquery顯示整個數組
我正在顯示基於正在點擊的選項卡的消息。當我不使用@ Html.Raw時,一切正常。沒有@ Html.Raw,我得到@ Html.Raw的一條消息,我得到了3條消息。我正在使用jquery來控制顯示內容。
如何使用@ Html.Raw顯示1條消息以便顯示Html解碼。
控制邏輯來構建陣列
customerVM.DisplayMessage = new[] { company.Tab_Footer_WebOrder_Message, company.Tab_Footer_Order_Message, company.Tab_Footer_Invoice_Message };
的Html @ Html.Raw(@ Model.DisplayMessage [I])應當僅顯示基於標籤1個消息被點擊。
<div>
@for (var i = 0; i < Model.DisplayMessage.Length; i++)
{
<p style="@(i == 0 ? "" : "display: none;")" id="[email protected](i + 1)" class="tab-description">@Html.Raw(@Model.DisplayMessage[i])</p>
}
</div>
jQuery的
$("#tabs").tabs({
activate: function (event, ui) {
var active = $('#tabs').tabs('option', 'active');
var getTab = $("#tabs ul>li a").eq(active).attr("href");
$(".tab-description").hide();
switch (getTab) {
case "#tabs-1":
$("#tab-description-1").show();
break;
case "#tabs-2":
$("#tab-description-2").show();
break;
case "#tabs-3":
$("#tab-description-3").show();
break;
}
}
})
是的。我也嘗試過並獲得相同的結果。 –
如果我刪除Html.Raw。我得到了我期待的結果。但刪除Html.Raw不會顯示Html解碼。 –