简体   繁体   中英

Loading aspx page with flushed image in jQuery dialog

I have page1.aspx witch is content page. On this page, on click event is triggered:

$("#lnkConsent").click(function (e) {
    var dlg = $("#divConsent").dialog();
    dlg.load('page2.aspx').dialog('open');
 });

html:

<div id="divConsent" title="Consent" class="UniversalDialog"></div>  

Page page2.aspx is an empty page, standard web form no serverside forms or heads:

<html xmlns="http://www.w3.org/1999/xhtml">
<head >
    <title></title>
</head>
<body>
    <form id="form1" >    <div></div>    </form>
</body>
</html>

C# code behind on page Page_Load:

Response.ContentType = "image/jpeg";
Response.Clear ( );
Response.BufferOutput = true;
Response.WriteFile ( Path.Combine ( Server.MapPath ( "~/foldername" ), filename);
Response.Flush ( );
Response.End ( );

When page2.aspx is called through address bar it works correctly: image is displayed but, when I try to load this page in dialog on Page1.aspx result is as is shown below:

在此处输入图片说明

Ofcourse, I would like to show this flushed picture in jQuery dialog loading page2.aspx in it.

What is my problem?

What I'm missing?

The load function you are using expects HTML back, which it never receives. Instead what you might want to do is to create an image tag with source as page2.aspx and then set it as a dialog content. Something along these lines (just an idea though, might need some adjustment):

$("#lnkConsent").click(function (e) {
    var dlg = $("#divConsent").dialog();
    var image = $('<img src="page2.aspx"/>');    
    dlg.html(image).dialog('open');
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM