Redirection to a page after printing document in google chrome

Posted by Kedarasp under ASP.NET on 4/14/2014 | Points: 10 | Views : 2647 | Status : [Member] | Replies : 0
I'm using google chrome web browser for running my application.
I faced a problem while after printing the document when I'm clicking on another button for redirection, it is not redirecting.
Here is the javascript code for printing:


<script type="text/javascript">
function Print() {
var PrintDiv = document.getElementById('<%=printDetails.ClientID %>');

PrintDiv.border = 0;
var PrintDivWindow = window.open('', '_blank', 'left=100,top=100,width=900,height=900,tollbar=0,scrollbars=1,status=0,resizable=4');
PrintDivWindow.document.write('<html>\n<head>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"../Styles/revisedStyle.css\">\n</head><body>');
PrintDivWindow.document.write(PrintDiv.outerHTML);
PrintDivWindow.document.write('</body>\n</html>');
PrintDivWindow.document.close();
PrintDivWindow.focus();
PrintDivWindow.print();
PrintDivWindow.close();
}

</script>


And this is the button below for printing:

<asp:Button ID="btnPrint" runat="server" Text="Print" Width="80px" OnClientClick="JavaScript:return Print();" />

After clicking on Print when I'm clicking on "Cancel" button for redirecting to home page, the page is not redirecting to "default.aspx" page. But if without clicking on Print Button, if I'm clicking on Cancel then it is working fine. Below code for Cancel Button Event.

protected void btnCancel_Click(object sender, EventArgs e)
{
try
{
Response.Redirect("default.aspx");
}
catch (Exception ee)
{
lblPrintErrmsg.Text = ee.Message.ToString();
lblPrintErrmsg.ForeColor = Color.Red;
}
}



I think this is a browser problem because it works fine in IE but not in Chrome.
But I need this to work fine in Google Chrome. Please give any suggestion.
Thank you.




Responses

(No response found.)

Login to post response