如何调用从后面页code js文件功能 [英] How to call js file function from code behind page
本文介绍了如何调用从后面页code js文件功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下的.js文件的功能,我需要保存记录后,从code中将其隐藏页。
我已经注册素文字文件中的aspx页面
aspx文件
<脚本类型=文/ JavaScript的SRC =/脚本/造访闪存report.js>< / SCRIPT>
.js文件
函数reloadDocTab(){警报('你好');
$('#frmDocs')ATTR('src'中,$('#frmDocs')ATTR(SRC));
}
页后面的 code
我已经试过了功能,但它不能正常工作
Page.ClientScript.RegisterOnSubmitStatement(ME [的GetType(),重装功能,返回reloadDocTab();。)
解决方案
尝试有一个这些:
Page.ClientScript.RegisterStartupScript(this.GetType(),ScriptKey,reloadDocTab(),真正的);
或
ClientScript.RegisterStartupScript(this.GetType(),ScriptKey,reloadDocTab(),真正的);
或
ScriptManager.RegisterStartupScript(this.GetType(),ScriptKey,reloadDocTab(),真正的);
我想你可能需要refrence的.js文件的头部标记
<头=服务器>
<脚本SRC =〜/脚本/造访闪存report.js>< / SCRIPT>
< /头>
I have following function in .js file and i need to call it from code behind page after saving a record.
I have registered scipt file in aspx page
aspx file
<script type="text/javascript" src="/scripts/visit-flash-report.js"></script>
.js file
function reloadDocTab() {
alert('hello');
$('#frmDocs').attr('src', $('#frmDocs').attr('src'));
}
Code behind page
I have tried the function but it is not working
Page.ClientScript.RegisterOnSubmitStatement(Me.[GetType](), "reload function", "return reloadDocTab();")
解决方案
Try one of these:
Page.ClientScript.RegisterStartupScript(this.GetType(), "ScriptKey", "reloadDocTab()", true);
OR
ClientScript.RegisterStartupScript(this.GetType(), "ScriptKey", "reloadDocTab()", true);
OR
ScriptManager.RegisterStartupScript(this.GetType(), "ScriptKey", "reloadDocTab()", true);
And i think you might need to refrence the .JS file in the head tag
<head runat="server">
<script src="~/scripts/visit-flash-report.js"></script>
</head>
这篇关于如何调用从后面页code js文件功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文