This is a migrated thread and some comments may be shown as answers.

[Solved] HTML in PanelBar item.Text

1 Answer 169 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
GrZeCh
Top achievements
Rank 2
GrZeCh asked on 19 Nov 2009, 12:04 AM
Hello,

is there possibility to put HTML in PanelBar item.Text? I wanted to do something like that:

item.Text = String.Format("<strong>{0}</strong> {1}",something,something2);

Thanks

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 23 Nov 2009, 09:10 AM
Hello GrZeCh,

Unfortunately you can not render Html, because  the panelbaritem text is rendered encoded. It is possible to implement ItemTemplate, which will replace the current rendered html for each item. The decision depends on the number of the requests for that feature.
Currently I can suggest you rebuild the Telerik.Web.Mvc.dll assenbly to render panelbaritem text not encoded.
Here is a code snippet showing how to modify the metod which rendered the item's html:
(In the PanelBarRenderer.cs)
private void CommonItemContent(PanelBarItem item)
        {
            if (item.Enabled)
            {
                string url = PanelBar.GetItemUrl(item, PanelBar.ViewContext, PanelBar.UrlGenerator);
 
                Writer.AddAttribute(HtmlTextWriterAttribute.Href, url, true);
            }
            Writer.RenderBeginTag(HtmlTextWriterTag.A);
 
            imageRenderer.WriteSprite(item);
            imageRenderer.WriteImage(item);
 
            Writer.WriteText(GetText(item));
 
            if (item.Items.Count > 0 || item.Content != null || !string.IsNullOrEmpty(item.ContentUrl))
            {
                if (item.Enabled && item.Expanded)
                {
                    Writer.AddAttribute(HtmlTextWriterAttribute.Class, "t-icon t-arrow-up", true);
                }
                else
                {
                    Writer.AddAttribute(HtmlTextWriterAttribute.Class, "t-icon t-arrow-down", true);
                }
 
                Writer.RenderBeginTag(HtmlTextWriterTag.Span);
                Writer.RenderEndTag();
            }
            Writer.RenderEndTag();
        }


Kind regards,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
PanelBar
Asked by
GrZeCh
Top achievements
Rank 2
Answers by
Georgi Krustev
Telerik team
Share this question
or