Javascript 传递“时无法使RegisterClientScriptBlock()方法工作”;“真的”;作为最后一个布尔参数
以下是尝试在页面中包含脚本的3个版本:Javascript 传递“时无法使RegisterClientScriptBlock()方法工作”;“真的”;作为最后一个布尔参数,javascript,asp.net,c#-4.0,registerclientscriptblock,Javascript,Asp.net,C# 4.0,Registerclientscriptblock,以下是尝试在页面中包含脚本的3个版本: Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "JqueryTestFile1", "<script type=\"text/javascript\" src=\"jqueryTEST1.js\"></script>", false); Page.ClientScript.RegisterClientScriptInclude(this.GetTy
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "JqueryTestFile1",
"<script type=\"text/javascript\" src=\"jqueryTEST1.js\"></script>", false);
Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "JqueryTestFile2",
"jquery-1.11.0.min.js");
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "JqueryTestFile3",
"src=\"jqueryTEST3.js\"", true);
其他信息::
[为了避免混淆,所有这些JS文件:JqueryTest1.JS
etc..都存在于我的解决方案中的适当位置]。在JqueryTest3.js
中,只有以下代码:
function DoClick(){
alert("Hi");
}
如果我将这个DoClick()
函数放在JqueryTest1.js
文件中,它就可以正常工作
.aspx
标记:
<form id="Form1" runat="server">
<input type="button" value="ClickMe" onclick="DoClick()" />
</form>
将代码替换为以下内容
ScriptManager.RegisterStartupScript(this,this.GetType(), "JqueryTestFile3",
"src=\"jqueryTEST3.js\"", true)
记住添加到您的页面
ScriptManager.RegisterStartupScript(this,this.GetType(), "JqueryTestFile3",
"src=\"jqueryTEST3.js\"", true)