Kendo UI - Turning Text() enclosed text into

2019-09-16 11:50发布

问题:

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);
  })
)