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";
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
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
<%@ 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
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
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
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)?
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.
Member
288 Points
886 Posts
Images in Popup window no longer works in Edge
Feb 07, 2021 10:14 PM|peterthegreat|LINK
Contributor
2090 Points
670 Posts
Re: Images in Popup window no longer works in Edge
Feb 08, 2021 08:26 AM|XuDong Peng|LINK
Hi peterthergreat,
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
Member
288 Points
886 Posts
Re: Images in Popup window no longer works in Edge
Feb 08, 2021 07:20 PM|peterthegreat|LINK
I hope it helps.
Contributor
2090 Points
670 Posts
Re: Images in Popup window no longer works in Edge
Feb 09, 2021 10:22 AM|XuDong Peng|LINK
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:
Here is a similar case, you could refer to it.
https://stackoverflow.com/questions/8733875/display-image-using-ashx-handler
Best regards,
Xudong Peng
Member
288 Points
886 Posts
Re: Images in Popup window no longer works in Edge
Feb 09, 2021 08:57 PM|peterthegreat|LINK
That did the trick.
It would be fine except windows blocks popups and not recommended! Is there a way of preventing that to happen?
All-Star
48510 Points
18072 Posts
Re: Images in Popup window no longer works in Edge
Feb 09, 2021 09:16 PM|PatriceSc|LINK
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.
Member
288 Points
886 Posts
Re: Images in Popup window no longer works in Edge
Feb 10, 2021 05:03 PM|peterthegreat|LINK
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)?
Member
288 Points
886 Posts
Re: Images in Popup window no longer works in Edge
Feb 10, 2021 05:41 PM|peterthegreat|LINK
Thanks
How do you get it to operate in a aspx file ?
All-Star
48510 Points
18072 Posts
Re: Images in Popup window no longer works in Edge
Feb 12, 2021 03:18 PM|PatriceSc|LINK
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.