开发者

OnClientClick event for keeping track of prints?

I am trying to keep track of prints that are made for a page. The page has Print this pa开发者_JS百科ge link. And the code for it is like below: This is written in .cs file as there are many conditions for displaying this. And i am appending here using String Builder.

sbOutput.AppendFormat("<td align=\"right\" valign=\"bottom\"><div style =\"float:right;text-align:right; valign:bottom;width:200px\"class=\"print_button notPrinted\"><a class=\"notPrinted\" href=\"#\" onclick=\"window.print();\">PRINT THIS COUPON </a><img src=\"images/print-icon-34x34.gif\" class=\"notPrinted\" align=\"absmiddle\" /></div> </td></tr></table>", couponid, Userid, locationid);

Do i have to use onclientclick or something else??

Thanks so much in advance.


Good option would be to write a Javascript function to enable Ajax call, so that you can send a request to server to record the print coomand.

<a href="return RecordPrint();">PRINT THIS COUPON</a>

function RecordPrint() {

// Make a AJAX Call to your server Page to record Print Command.
// printRecorded : success from server

If(printRecorded)
{
  window.print();
}

return false;

}

Hope that helps.


since you seem to print on the client side only, you could do

<a href=\"counter.aspx\" onclick=\"window.print();\">PRINT THIS COUPON </a>

On the server side, implement the counter.aspx page to just count the request and quit silently. Make sure, the window.print() will return true - otherwise the link is not executed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜