Run JavaScript from C# ASP.NET -
i'm trying run javascript function code behind in c#. looked @ many resourses on internet far no luck. not work simple sample code have:
code behind:
protected void button2_click(object sender, eventargs e) { scriptmanager.registerstartupscript(this,gettype(),"a","a();", true); }
in aspx file:
<script type="text/javascript"> function a() { var = 0; } </script>
when run :
0x800a1391 - javascript runtime error: 'a' undefined
note :
also tried :
- scriptmanager.registerstartupscript(this,gettype(),"a","a()", true);
- scriptmanager.registerstartupscript(this,gettype(),"a","a", true);
still getting same error.
note future reader: trick use asp update panel. did not found single source point important fact.
- use scriptmanager.registerstartupscript anywhere long inside
updatepanel
now tell a()
javascript function :
scriptmanager.registerstartupscript(this,gettype(),"a","javascript:a();", true);
Comments
Post a Comment