javascript - Unable to get the RegisterClientScriptBlock() method to work when passing "true" as last Boolean parameter -
here 3 versions tried include scripts in page:
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);
the first 2 versions working fine . 3rd 1 "true"
last parameter rendering <![cdata[
in source code , can't work.
why rendering cdata ? purpose serves in context? how can third version working without removing "true" parameter ? below html code rendered in browser::
<form method="post" action="scriptsmanager.aspx" id="form1"> <script type="text/javascript" src="jquerytest1.js"></script> <script src="jquery-1.11.0.min.js" type="text/javascript"></script> <script type="text/javascript"> //<![cdata[ src="jquerytest3.js"//]]> </script> <input type="button" value="clickme" onclick="doclick()" /> </form>
additional info::
[ avoiding confusion these js files: jquerytest1.js
etc.. present @ proper location in solution ]. in jquerytest3.js
, have below code:
function doclick(){ alert("hi"); }
if place doclick()
function in jquerytest1.js
file, works perfectly.
.aspx
markup:
<form id="form1" runat="server"> <input type="button" value="clickme" onclick="doclick()" /> </form>
replace code following
scriptmanager.registerstartupscript(this,this.gettype(), "jquerytestfile3", "src=\"jquerytest3.js\"", true)
remember add page
Comments
Post a Comment