I have a javascript that prints a crystal report. It works well. Except for the part where I need to send a value to the button to delete a specific image. I am trying to send "Printed" to the button as trigger.
<script type="text/javascript">
function Printing() {
var dvReport = document.getElementById("dvReport");
var frame1 = dvReport.getElementsByTagName("iframe")[0];
var printvalue = document.createElement("INPUT");
printvalue.type = "hidden";
printvalue.name = "printvalue";
if (navigator.appName.indexOf("Internet Explorer") != -1 || navigator.appVersion.indexOf("Trident") != -1) {
frame1.name = frame1.id;
window.frames[frame1.id].focus();
window.frames[frame1.id].print();
printvalue.value = "Printed";
document.forms[0].appendChild(printvalue);
}
else {
var frameDoc = frame1.contentWindow ? frame1.contentWindow : frame1.contentDocument.document ? frame1.contentDocument.document : frame1.contentDocument;
frameDoc.print();
printvalue.value = "Printed";
document.forms[0].appendChild(printvalue);
}
}
</script>
This is how I call the javascript
<asp:Button ID="Print" runat="server" Text="PRINT"
OnClientClick="Printing();" />
This is my button click. Javascript is triggered but not sending the value in button click when printing is DONE/cancelled.
Protected Sub keywordSearch_Click(sender As Object, e As EventArgs) Handles keywordSearch.Click
Dim printvalue As String = Request.Form("printvalue")
If printvalue = "Printed" Then
deletepic(Session("Request"))
setStatus("DELETED! PRINTED!")
End If
End Sub
What I have tried:
I've tried putting the value and calling it in another function and is working well but when I try to merge it with the printing function the value cant be passed.
I also Tried this javascript. the button is triggered only if the Print Preview was cancelled but when Printing is executed. It wont trigger at all.
What am i missing?
function Tryial() {
var dvReport = document.getElementById("dvReport");
var frame1 = dvReport.getElementsByTagName("iframe")[0];
var frameDoc = frame1.contentWindow ? frame1.contentWindow : frame1.contentDocument.document ? frame1.contentDocument.document : frame1.contentDocument;
frameDoc.print();
var print_value = document.createElement("INPUT");
print_value.type = "hidden";
print_value.name = "print_value";
print_value.value = "Printed";
document.forms[0].appendChild(print_value);
}