我在asp.net中使用fullcalendar。我需要让它在月视图上显示时间和位置。我尝试过使用:
cevent.title = cevent.title + "At: " + (string)reader["Location"] + "<br>";
但是正在净化HTML并显示<br />
而不是应用换行符。如何强制它使用HTML?
谢谢
我尝试过HTML编码和解码,并使用/ n非这些工作。显然cevent.description可以接受HTML标签,但不能接受cevent.title以下是我正在使用的更多代码。
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可以正常运行,但cevent.title只是显示它们。
答案 0 :(得分:0)
你试过吗?
cevent.title += "At: " + Server.HtmlDecode( (string)reader["Location"] + "<br>" );
或
您可能需要完整参考
HttpContext.Current.Server.HtmlDecode()
尝试使用Environment.NewLine,如下所示:
cevent.title += "At: " + Server.HtmlDecode( (string)reader["Location"] + Environment.NewLine);
答案 1 :(得分:0)
我是网站的新手,我不知道有关交叉发布答案的规则,但我在这里使用jQuery的append()和fullCalendar的eventRender发布了一个技巧: