c# - Call Javascript method from code behind -


i have function in javascript makes label invisible. want call function code behind. not able make invisible. here both lines of code.

c# code behind:

          page.clientscript.registerstartupscript(gettype(), "myfunction", "myfunction();", true); 

javascript:

         <script type ="text/javascript" language="javascript">           function myfunction()           {                  document.getelementbyid("label8").style.display = 'none';            }           </script> 

pls let me know if there mistake. looks control not going method definition only.

thank you

use clientid of server control (label) in getelementbyid or set clientidmode static label , make sure availability of html elements script, can put script tag before closing tag of body

<script type ="text/javascript" language="javascript">       function myfunction()       {           document.getelementbyid("<%= label8.clientid %>").style.display = 'none';           } </script> 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -