javascript - "Page.ClientScript.RegisterClientScriptBlock" not working while "ScriptManager.RegisterClientScriptBlock" -
i trying figure why page.clientscript.registerclientscriptblock
not working while scriptmanager.registerclientscriptblock
do work
my code using code:
this.page.clientscript.registerclientscriptblock(gettype(), "headercomment", "<script>not working</script>", false);
in past used work
so tried solution , did find master page dont contain <form id="form1" runat="server">
when added form
tag this.page.clientscript.registerclientscriptblock
didn't work, , tried use scriptmanager.registerclientscriptblock(this.page, gettype(), "headercomment", "<script>working</script>", false);
, worked.
i prefer use page.clientscript.registerclientscriptblock
, not scriptmanager.registerclientscriptblock
way won't need change existing working code.
i didn't find differences if there between those.. , scriptmanager.registerclientscriptblock
changes cause change in application.
what can reason that:
this.page.clientscript.registerclientscriptblock(gettype(), "headercomment", "<script>not working using 'page.clientscript.registerclientscriptblock'</script>", false);
is not working?
the solution worked me wrap body content of master page form
tag runat="server"
attribute:
<body> <form id="form1" runat="server"> ... ... </form> </body>
then code behind page runs within master page following code works
page.clientscript.registerclientscriptblock(gettype(), "scriptid", "<script>console.log('working');</script>", false);
Comments
Post a Comment