Answered by:
Images in Popup window no longer works in Edge

Question
-
User1909155429 posted
I have recently upgraded windows to version 10 that uses the new Edge browser. i can open a new window but the image will not show except for code output from datatable file? I know that the images can be loaded in data control but not in browser window? nw = window.open("", "window", ",,scrollbar=yes,toolbar=no,menubar=no"); nw.location.href = "FullImage.ashx?ID=" + id + "&type=no";Sunday, February 7, 2021 10:14 PM
Answers
-
User-939850651 posted
Hi peterthegreat,
According to the code you provided, there seems to be a related query in your query (I'm not sure if it is), but you have not set the contentType of its response,you could try something like this:
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest Dim imageid As String = context.Request.QueryString("ID") Dim connection As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("connectionString").ConnectionString) connection.Open() Dim command As SqlCommand = New SqlCommand("SELECT photo,contentType,id,primarykey from Mail_Images where primarykey=" & imageid, connection) Dim dr As SqlDataReader = command.ExecuteReader() context.Response.ContentType = "image/png" If dr.HasRows Then dr.Read() context.Response.BinaryWrite(CType(dr(0), Byte())) Else context.Response.Write("System failure occured:No Image returned!!!") End If connection.Close() context.Response.[End]() End Sub
Here is a similar case, you could refer to it.
https://stackoverflow.com/questions/8733875/display-image-using-ashx-handler
Best regards,
Xudong Peng
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, February 9, 2021 10:22 AM
All replies
-
User-939850651 posted
Hi peterthergreat,
I have recently upgraded windows to version 10 that uses the new Edge browser. i can open a new window but the image will not show except for code output from datatable file?You mentioned that the Windows version has been updated. Will such a problem occur when you use the previous version of Windows? Will such a problem occur in other browsers?
Because I am not sure whether there are other problems with the code script code (or other code) or the file in the data sheet you provided. If possible, please provide relevant sample code so that we can reproduce your problem.
Best regards,
Xudong Peng
Monday, February 8, 2021 8:26 AM -
User1909155429 posted
<script language="javascript" type="text/javascript"> function popwin(id) { nw = window.open("", "window", ",,scrollbar=yes,toolbar=no,menubar=no"); nw.location.href = "FullImage.ashx?ID=" + id; nw = null; } </script> <a onclick="popwin('<%# Eval("PrimaryKey")%>');return false;"> <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("PrimaryKey", "ThumbNailImage.ashx?ID={0}") %>' /> </a>
<%@ WebHandler Language="VB" Class="Handler" %> Imports System Imports System.Web Imports System.Data.SqlClient Imports System.Configuration Imports System.Data Public Class Handler : Implements IHttpHandler Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest Dim imageid As String = context.Request.QueryString("ID") Dim connection As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("connectionString").ConnectionString) connection.Open() Dim command As SqlCommand = New SqlCommand("SELECT photo,contentType,id,primarykey from Mail_Images where primarykey=" & imageid, connection) Dim dr As SqlDataReader = command.ExecuteReader() If dr.HasRows Then dr.Read() context.Response.BinaryWrite(CType(dr(0), Byte())) Else context.Response.Write("System failure occured:No Image returned!!!") End If connection.Close() context.Response.[End]() End Sub Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable Get Return False End Get End Property End Class
I hope it helps.
Monday, February 8, 2021 7:20 PM -
User-939850651 posted
Hi peterthegreat,
According to the code you provided, there seems to be a related query in your query (I'm not sure if it is), but you have not set the contentType of its response,you could try something like this:
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest Dim imageid As String = context.Request.QueryString("ID") Dim connection As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("connectionString").ConnectionString) connection.Open() Dim command As SqlCommand = New SqlCommand("SELECT photo,contentType,id,primarykey from Mail_Images where primarykey=" & imageid, connection) Dim dr As SqlDataReader = command.ExecuteReader() context.Response.ContentType = "image/png" If dr.HasRows Then dr.Read() context.Response.BinaryWrite(CType(dr(0), Byte())) Else context.Response.Write("System failure occured:No Image returned!!!") End If connection.Close() context.Response.[End]() End Sub
Here is a similar case, you could refer to it.
https://stackoverflow.com/questions/8733875/display-image-using-ashx-handler
Best regards,
Xudong Peng
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, February 9, 2021 10:22 AM -
User1909155429 posted
That did the trick.
It would be fine except windows blocks popups and not recommended! Is there a way of preventing that to happen?
Tuesday, February 9, 2021 8:57 PM -
User753101303 posted
Hi,
The general idea is to use a HTM. fragment embedded in your page shown on top of other page elements such as https://www.w3schools.com/howto/howto_css_modals.asp or https://keithjgrant.com/posts/2018/01/meet-the-new-dialog-element/
You have also that in most CSS system or JS librariries.
Tuesday, February 9, 2021 9:16 PM -
User1909155429 posted
Instead of open window i tried insert on the page itself called by javascript function and injected into html image. Works with image types except it wont return different document format such as PDF ( i.e application/pdf)?
<img id="imgFull" runat="server" alt="" src="" />
Wednesday, February 10, 2021 5:03 PM -
User1909155429 posted
Thanks
How do you get it to operate in a aspx file ?
Wednesday, February 10, 2021 5:41 PM -
User753101303 posted
img is for images. Try https://developer.mozilla.org/fr/docs/Web/HTML/Element/object instead if not showing always the same kind of content.
Not sure if the 2nd quesrion is the same ie you have an ASHX handler delivering some content (images, PDF, maybe other ?) that you want to show from within an ASPX page.
Friday, February 12, 2021 3:18 PM