open new window from server side on button click
-
Hi all, I would like to open new window on button click from sever side and write HTML content to it. I have written following code but this writes the HTML content to the main window instead of the new opened window.
protected void btnClick_Click(object sender, EventArgs e)
{
Response.Write("<SCRIPT LANGUAGE=\"JavaScript\">\n");
Response.Write("window.open( '','popup','toolbar=no,menubar=no,scrollbars=1,width=750,height=800')");
Response.Write("</script>");
Response.Write("<html><head>");
Response.Write("</head><body>");
Response.Write("<div id='lnk' class='noprint' style='text-align:right'>");
Response.Write("<a href='#' onclick='window.print();return false;'>Print</a> ");
Response.Write("<a href='#' onclick='window.close();return false;'>Close</a>");
Response.Write("</div>");
Response.Write("<div id='printv' class='print'>");
Response.Write("This is test");
Response.Write("</div>");}
can anyone please suggest me how can I achieve this? Thanks a lot.
-
Hi all, I would like to open new window on button click from sever side and write HTML content to it. I have written following code but this writes the HTML content to the main window instead of the new opened window.
protected void btnClick_Click(object sender, EventArgs e)
{
Response.Write("<SCRIPT LANGUAGE=\"JavaScript\">\n");
Response.Write("window.open( '','popup','toolbar=no,menubar=no,scrollbars=1,width=750,height=800')");
Response.Write("</script>");
Response.Write("<html><head>");
Response.Write("</head><body>");
Response.Write("<div id='lnk' class='noprint' style='text-align:right'>");
Response.Write("<a href='#' onclick='window.print();return false;'>Print</a> ");
Response.Write("<a href='#' onclick='window.close();return false;'>Close</a>");
Response.Write("</div>");
Response.Write("<div id='printv' class='print'>");
Response.Write("This is test");
Response.Write("</div>");}
can anyone please suggest me how can I achieve this? Thanks a lot.
Check this out:
function Clickheretoprint(){ var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,"; disp_setting+="scrollbars=yes,width=650, height=600, left=100, top=0"; var content_vlue = document.getElementById("print_content").innerHTML; var docprint=window.open("","",disp_setting); docprint.document.open(); docprint.document.write(''); docprint.document.write(' '); docprint.document.write(' '); docprint.document.write(content_vlue); docprint.document.write(' '); docprint.document.write(' '); docprint.document.close(); docprint.focus(); }
Source Courtesy: http://forum.java.sun.com/thread.jspa?threadID=5279919&messageID=10175156[^]Vasudevan Deepak Kumar Personal Homepage
Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson