Kendo UI - Turning Text() enclosed text into

2019-09-16 12:06发布

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条回答
该账号已被封号
2楼-- · 2019-09-16 12:35

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);
  })
)
查看更多
登录 后发表回答