问题
I am trying to add style to title of a panel bar that comes with Kendo UI
and I want to break this pure text of Blah-1 Blah-2
into 2 span blocks so it outputs html as <span>Blah-1</span>
and <span>Blah -2</span>
How do I achieve that with the following?
@(Html.Kendo().PanelBar()
.Name("panelBar")
.Items(panelBar =>
{
panelBar.Add().Text("Blah-1 Blah-2")
})
)
I've tried to encode <span>
within Text()
but it doesn't escape html tags.
回答1:
The Encode
method allows you to stop HTML encoding (done by default):
@(Html.Kendo().PanelBar()
.Name("panelBar")
.Items(panelBar =>
{
panelBar.Add().Text("<span>Blah-1</span><span>Blah-2</span>").Encoded(false);
})
)
来源:https://stackoverflow.com/questions/20184242/kendo-ui-turning-text-enclosed-text-into-span-encoded-html