我有一个ASP.NET网页表单。这个网页表单有一个事件处理程序,用于生成一些HTML。这个HTML是基于当天的时间,所以它是在事件处理程序中创建的。根据当天的时间,通过以下方法编程地创建一个图像:
private Bitmap GetImageForTime(DateTime time)
{
Bitmap bitmap = new Bitmap();
// Dynamically build the bitmap...
return bitmap;
}
我希望在生成HTML时调用此方法。但是,我不想将图像写入服务器。相反,我想找出一种方法将其与HTML一起写出。从某种意义上说,我正在尝试实现以下目标:
protected void myLiteral_Load(object sender, EventArgs e)
{
string html = "<table><tr><td>";
html += GetImageForTime(DateTime.Now); // This is the problem because it's binary.
html += "</td><td>";
html += GetWeatherHtmlText();
html += "</td></tr></table>";
myLiteral.Text = html;
}
这是否可能?如果是,该如何实现?