This has been absolutely baffling me. The following code works:

<a href="javascript:void(0);" onclick="openPopUp('Edit_Screen.aspx?Image_Id='+ '<%# Eval("Image_Id") %>','Popup',850,800);">
                         <%# Eval("ReferenceNumber") %>
</a>

Which calls this:

function openPopUp(pageURL, title, popupWidth, popupHeight) {
  var targetPop = null;
  var left = (screen.width / 2) - (popupWidth / 2);
  var top = (screen.height / 2) - (popupHeight / 2);
  targetPop = window.open(pageURL, title, 'toolbar=no, status=no, menubar=no, width=' + popupWidth + ', height=' + popupHeight + ', top=' + top + ', left=' + left).focus();

}

This code does not work:

<asp:Button ID="btnNewRecord" runat="server" Text="Enter New Record" CssClass = "button" OnClientClick="LaunchImage()" />

Which calls this:

function LaunchImage()
{
   debugger;
   openPopUp("Insert_Screen.aspx?dataType=images", "Popup", 750, 650);
}

And that calls the same openPopUp function that was shown above. The first a href code example calls the popup and keeps the focus on the popup. The second, which is called from the ASP button, calls the popup, and then gives the focus back to the screen that called it. Does anyone have any idea why? This has been baffling me for awhile now.

Thanks ahead of time!

Related posts

Recent Viewed