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.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);
精彩评论