I have a page that is creating an image with the current time, and uses an UpdatePanel to refresh the image every second. It works fine in Chrome, but when I look at it in Internet Explorer, it's static, it does not refresh. If I refresh the page, it refreshes
with the current time, but still does not update automatically.
I also have a Label control doing the same thing, getting the current date and time. In both IE and Chrome it refreshes every second, so I know my UpdatePanel is working correctly. Seems like there might be an issue with doing a DataBind() on an Image
in IE?
string currentTime = DateTime.Now.ToString();
Bitmap oCanvas;
oCanvas = new Bitmap(250, 50);
Graphics g = Graphics.FromImage(oCanvas);
g.Clear(Color.White);
FontFamily fontfml = new FontFamily(GenericFontFamilies.Serif);
Font font = new Font(fontfml, 15);
SolidBrush brush = new SolidBrush(Color.Black);
g.DrawString(currentTime, font, brush, 15, 15);
// Now, we only need to send it to the client
Response.ContentType = "image/jpeg";
oCanvas.Save(Response.OutputStream, ImageFormat.Jpeg);
Response.End();
// Cleanup
g.Dispose();
oCanvas.Dispose();
mat.mdig
Member
31 Points
29 Posts
Image.DataBind in UpdatePanel not working in IE9, but works in Chrome
Dec 04, 2012 10:22 PM|LINK
I have a page that is creating an image with the current time, and uses an UpdatePanel to refresh the image every second. It works fine in Chrome, but when I look at it in Internet Explorer, it's static, it does not refresh. If I refresh the page, it refreshes with the current time, but still does not update automatically.
I also have a Label control doing the same thing, getting the current date and time. In both IE and Chrome it refreshes every second, so I know my UpdatePanel is working correctly. Seems like there might be an issue with doing a DataBind() on an Image in IE?
<form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="upTimeImage" runat="server" UpdateMode="conditional" ChildrenAsTriggers="true"> <ContentTemplate> <asp:Timer ID="tTimeImage" runat="server" Interval="1000" OnTick="tTimeImage_Tick"></asp:Timer> <asp:Image ID="imgTimeImage" runat="server" ImageUrl="~/TimeImage.aspx"/> <br /> <asp:Label runat="server" Text="" ID="lblTime"></asp:Label> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="tTimeImage" /> </Triggers> </asp:UpdatePanel> </div> </form>protected void tTimeImage_Tick(object sender, EventArgs e) { imgTimeImage.DataBind(); string currentTime = DateTime.Now.ToString(); lblTime.Text = currentTime; }Image:
string currentTime = DateTime.Now.ToString(); Bitmap oCanvas; oCanvas = new Bitmap(250, 50); Graphics g = Graphics.FromImage(oCanvas); g.Clear(Color.White); FontFamily fontfml = new FontFamily(GenericFontFamilies.Serif); Font font = new Font(fontfml, 15); SolidBrush brush = new SolidBrush(Color.Black); g.DrawString(currentTime, font, brush, 15, 15); // Now, we only need to send it to the client Response.ContentType = "image/jpeg"; oCanvas.Save(Response.OutputStream, ImageFormat.Jpeg); Response.End(); // Cleanup g.Dispose(); oCanvas.Dispose();oned_gk
All-Star
31709 Points
6477 Posts
Re: Image.DataBind in UpdatePanel not working in IE9, but works in Chrome
Dec 05, 2012 01:49 AM|LINK
Try using deferent url address by generate number for querystring, just make deference url