如何从代码后面调用javascript函数 [英] How to call javascript function from code behind
本文介绍了如何从代码后面调用javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想打印asp面板但是当我从后面的代码调用js函数时它给了我这个错误
JavaScript运行时错误:无法获取属性'getElementsByTagName'未定义或空引用
如何解决此错误????
我的剧本是
I want to print asp panel but when i call js function from code behind it gives me this error
JavaScript runtime error: Unable to get property 'getElementsByTagName' of undefined or null reference
how to solve this error????
my script is
<script>
function printform()
{
var printContent = document.getElementById('<%= PNL_PrxStatus.ClientID %>');
var btn = printContent.getElementsByTagName("input");
var windowUrl = 'about:blank';
var uniqueName = new Date();
var windowName = 'Print' + uniqueName.getTime();
var printWindow = window.open(windowUrl, windowName, 'left=0,top=0,width=0,height=0');
printContent.setAttribute("Position", "absolute");
printContent.setAttribute("Top", "1291px");
printContent.setAttribute("Left", "1341px");
btn[0].style.display = 'none';
printWindow.document.write(printContent.innerHTML);
printWindow.document.close();
printWindow.focus();
printWindow.print();
printWindow.close();
}
</script>
和我的代码behide是这个
ScriptManager.RegisterClientScriptBlock(Me.Page,GetType(String),PrintForm,printform();,true)
thnx提前....
and my code behide is this
ScriptManager.RegisterClientScriptBlock(Me.Page, GetType(String), "PrintForm", "printform();", true)
thnx in advance....
推荐答案
尝试这个,,,,,: )
TRY THIS,,,,, :)
Page.ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "printform();", true);
这篇关于如何从代码后面调用javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文