本文介绍了如何在asp.net中没有按钮点击事件的情况下调用java脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我在asp.net上报告 我用一页报告设计 点击打印选项时然后不要去设计页面直接显示打印选项页面 我的代码正在打印点击按钮是 会话[ Memo_No] = txt_Memo_no.Text; ScriptManager.RegisterStartupScript( this , typeof ( string ), OPEN_WINDOW, var Mleft =(screen.width / 2) - (900/2); var Mtop =(screen.height / 2) - (500/2); window。 open('Memo_Print.aspx',null,'height = 500,width = 900,status = yes,toolbar = no,scrollbars = yes,menubar = no,location = no,top = \'+ Mtop + \', left = \'+ Mleft + \'');, true ); 和我调用javascript打印选项是在页面加载事件是 字符串 printScript = @ 函数PrintGridView () { var gridInsideDiv = document.getElementById('grd_d iv'); / * var printWindow = window.open('gview.htm','PrintWindow','letf = 0,top = 0,width = 800,height = 600,toolbar = 1,scrollbars = 1,status = 1'); * / var printWindow = window.open(); printWindow.document.write(gridInsideDiv.innerHTML); printWindow.document.close(); printWindow.focus(); printWindow.print(); printWindow.close(); }; 此 .ClientScript.RegisterStartupScript(Page.GetType(), PrintGridView,printScript.ToString(), true ); btn_print.Attributes.Add( onclick, PrintGridView();); 请帮助我 提前谢谢解决方案 hi,I am making the reports in asp.net I use one page for reports design When Click the print option then don''t go to design page directly show the print option pagemy code is on print Click button isSession["Memo_No"] = txt_Memo_no.Text; ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", "var Mleft = (screen.width/2)-(900/2);var Mtop = (screen.height/2)-(500/2);window.open( 'Memo_Print.aspx', null, 'height=500,width=900,status=yes,toolbar=no,scrollbars=yes,menubar=no,location=no,top=\'+Mtop+\', left=\'+Mleft+\'' );", true); and I Call the javascript for print option is on page load event is string printScript = @"function PrintGridView() { var gridInsideDiv = document.getElementById('grd_div'); /*var printWindow = window.open('gview.htm','PrintWindow','letf=0,top=0,width=800,height=600,toolbar=1,scrollbars=1,status=1');*/ var printWindow = window.open(); printWindow.document.write(gridInsideDiv.innerHTML); printWindow.document.close(); printWindow.focus(); printWindow.print(); printWindow.close(); }"; this.ClientScript.RegisterStartupScript(Page.GetType(), "PrintGridView", printScript.ToString(), true); btn_print.Attributes.Add("onclick", "PrintGridView();");Please Help MeThanks in advance 解决方案 这篇关于如何在asp.net中没有按钮点击事件的情况下调用java脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-19 01:45