0

I am using fullcalendar in asp.net. I need to have it display the time and location on the month view. I have tried using:

cevent.title = cevent.title + "At: " + (string)reader["Location"] + "<br>";

but is is purifying the HTML and displaying <br /> rather then applying the line break. How can I force it to use the HTML?

Thank you

I have tried HTML encoding and decoding and using /n non of these work. Apparently cevent.description can accept HTML tags but not cevent.title Here is more of the code I am using.

public static List<CalendarEvent> getEvents(DateTime start, DateTime end)
{

    List<CalendarEvent> events = new List<CalendarEvent>();
    SqlConnection con = new SqlConnection(connectionString);
    SqlCommand cmd = new SqlCommand("SELECT eventNumber, details, event, BeginDate, BeginTime, EndDate, EndTime, Location FROM events where BeginDate>=@start AND EndDate<=@end", con);
    cmd.Parameters.AddWithValue("@start", start);
    cmd.Parameters.AddWithValue("@end", end);

    using (con)
    {
        con.Open();
        SqlDataReader reader = cmd.ExecuteReader();
        while (reader.Read())
        {
            CalendarEvent cevent = new CalendarEvent();
            cevent.id = (int)reader["eventNumber"];
            cevent.title = (string)reader["event"];
            cevent.description = "<B>" + cevent.title + "</B><br/><br/>";
            if (!string.IsNullOrEmpty((string)reader["BeginTime"]))
            {
                cevent.description = cevent.description + (string)reader["BeginTime"] + " - " + (string)reader["EndTime"] + "<br>";
            }
            if (!string.IsNullOrEmpty((string)reader["Location"]))
            {
                cevent.description = cevent.description + "At: " + (string)reader["Location"] + "<br>";
            }
            cevent.description = cevent.description + (string)reader["details"];

            cevent.start = (DateTime)reader["BeginDate"];
            cevent.end = (DateTime)reader["EndDate"];
            events.Add(cevent);
        }
    }
    return events;
}

cevent.description functions properly with the
tages but cevent.title simply displays them.

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
RDO
  • 41
  • 1
  • 4

1 Answers1

0

Have you tried?

cevent.title += "At: " + Server.HtmlDecode( (string)reader["Location"] + "<br>" );

or

You might need the full reference

HttpContext.Current.Server.HtmlDecode()

Try using Environment.NewLine as shown below:

cevent.title += "At: " + Server.HtmlDecode( (string)reader["Location"] + Environment.NewLine);

Sparky
  • 14,967
  • 2
  • 31
  • 45
  • Just on another thought, try replacing the
    with \n It might be the control's title is not using HTML at all, but rather straight text
    – Sparky Dec 17 '10 at 11:14