在全日历中去净化 HTML
我在 asp.net 中使用 fullcalendar。我需要让它在月视图上显示时间和位置。我尝试过使用:
cevent.title = cevent.title + "At: " + (string)reader["Location"] + "<br>";
但它正在净化 HTML 并显示
而不是应用换行符。我怎样才能强制它使用 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 只是显示它们。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你尝试过吗?
或者
您可能需要完整的参考
HttpContext.Current.Server.HtmlDecode()
尝试使用 Environment.NewLine,如下所示:
cevent.title += "At: " + Server.HtmlDecode( ( string)reader["位置"] + Environment.NewLine);
Have you tried?
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);