search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Event test

Related article: ASP.NET Calendar: Integration with Date Picker (C#, VB.NET)
Asked by Mike
2 years ago.

How do I add a line break in the Event Name display when combining variables into a string for the Event Name? I tried adding CHAR(10) & CHAR(13) but it appears to be ignoring the characters.

Answer posted by Dan Letecky [DayPilot]
2 years ago.

The event text gets HTML-encoded (as a protection against XSS attacks) and then it is treated as HTML. That means ASCII line breaks will be ignored.

If you need to insert a line break, you'll have to use the BeforeEventRender event and build the HTML manually.

Example:

protected void DayPilotCalendar1_BeforeEventRender(object sender, BeforeEventRenderEventArgs e)
{ 
      e.Html = HttpUtility.HtmlEncode(e.Text) + "<br/>" + "Another line";
}

Don't forget the HTML-encode the input text (e.g. using HttpUtility.HtmlEncode() like in the example above).

See also:
https://doc.daypilot.org/calendar/event-customization/

Comment posted by Mike
2 years ago.

This solution did not work for me but I did follow the link you provided and tried the e.Html = e.Text; command with the <br/> already embedded in the text and that worked.
Thanks for your valuable assistance!

Comment posted by Dan Letecky [DayPilot]
2 years ago.

Great, thanks for posting your solution!

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.