I've been completely puzzled by this issue. Here is a working example of the code:
<a href="javascript:void(0);" onclick="openPopUp('Edit_Screen.aspx?Image_Id='+ '<%# Eval("Image_Id") %>','Popup',850,800);">
<%# Eval("ReferenceNumber") %>
</a>
Which triggers the following function:
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 piece of code does not work as expected:
<asp:Button ID="btnNewRecord" runat="server" Text="Enter New Record" CssClass = "button" OnClientClick="LaunchImage()" />
Which calls the following function:
function LaunchImage()
{
debugger;
openPopUp("Insert_Screen.aspx?dataType=images", "Popup", 750, 650);
}
Both functions call the same openPopUp function. The first code example using an anchor tag keeps focus on the pop-up, while the second code triggered by the ASP button gives back focus to the calling screen. I can't figure out why this difference exists. It's been bothering me for quite some time now.
Any insights are greatly appreciated!