2

In my C# web application, I have one page with a panel control:

ViewTask.aspx    
<asp:Panel ID="panelImageThumbnails" runat="server" Style="width: 100%;">

This panel gets filled using jQuery .load with page ThumbnailPanel.aspx

<script type="text/javascript">
    $(window).load(function () {
        LoadThumbnails();
    });
    function LoadThumbnails() {
        $("#panelImageThumbnails").empty();
        var imglink = "<span style='text-align: center; align-content:center'>Getting thumbnails, please wait!<br><br><img src='Images/loader.gif'><br><br></span>";
        $("#panelImageThumbnails").append(imglink);
        $('#panelImageThumbnails').load('ThumbnailPanel.aspx').hide().fadeIn(1000);
        return false;
    }

</script>

Inside ThumbnailPanel.aspx, I query a table for a list of images and then loop over the DataTable and write them each to another panel each as ImageButtons

                //Add a new image button to the thumbnail panel
                ImageButton newImageButton = new ImageButton();
                newImageButton.ID = "ib_" + row["Screenshot_ID"].ToString();
                newImageButton.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(bytes);
                newImageButton.PostBackUrl = "ViewImage.aspx?fileName=" + row["Screenshot_ID"].ToString() + ".png";
                newImageButton.OnClientClick = "target='_blank'";
                newImageButton.CssClass = "thumbnailButton";
                newImageButton.ToolTip = row["Screenshot_Created"].ToString() + "(" + row["Screenshot_CreatedBy"].ToString() + ")";
                newImageButton.AlternateText = row["Screenshot_Title"].ToString();
                panelUploadedImageThumbnails.Controls.Add(new LiteralControl("<table border='1' style='border-collapse: collapse;' class='inlineTable'><tr><td style='font-size:7pt;'>" + row["Screenshot_Title"].ToString() + "</td></tr><tr><td>"));
                panelUploadedImageThumbnails.Controls.Add(newImageButton);
                panelUploadedImageThumbnails.Controls.Add(new LiteralControl("</td></tr></table>"));

I set the PostBackUrl to page "ViewImage" and feed in the Screenshot_ID. This page converts the image to a bytearray and prints it to the screen.

ThumbnailPanel.aspx works perfectly on its own. But when it's loaded into panelImageThumbnails during the jQuery .load inside ViewTask.aspx all of the hyperlinks point to ThumbnailPanel.aspx instead of ViewImage.aspx.

Any idea how I can fix my desired PostBackUrl from being ignored?

Kari
  • 43
  • 4
  • Side note, I tried changing panel to a div and the same behavior happens. I also changed it to an iframe where I set the src of the iframe from the codebehind on load (rather than using jquery .load) and this version works fine. So it seems like the problem happens with use of jquery .load (or possibly panel & div). – Kari Mar 05 '17 at 14:30

0 Answers0