Reputation: 9621
I have a link in an update panel which calls a js method to do printing of the current window:
<a href="javascript:print()" id="cpMain_popupCouponDescriptionControl_hrefPrint">Print Coupon</a>
where the js method is called on Page_Load event:
private void loadJs()
{
String flashMap = "script";
if (!Page.ClientScript.IsClientScriptBlockRegistered(this.Page.GetType(), flashMap))
{
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), flashMap, "function print(){ alert('test'); window.print(); return false; }", true);
}
}
When pressing the link, the alert window is shown multiple times (after I click "Ok", which seems strange) but window.print() is never called (a new tab for printing is not opened).
If I directly call javascript:window.link
from href
it works, but because the link is contained in an update panel, it no longer works second time (that's why I tried to register the script).
Can anybody see the issue here?
Upvotes: 1
Views: 105
Reputation: 26177
I believe window.print();
is actually calling your print()
function recursively. Try changing the name of your js function.
Upvotes: 1