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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

Making Empty C++ Project: General exception (Exception from HRESULT:0x80131500) Visual Studio Community 2015 -

How to fix java warning for "The value of the local variable is not used " -