C# .NET - Calling javascript function - Asked By Nitish Gupta on 10-Sep-12 06:46 AM

hello,

I am using javascript function..in Asp.net C#

<style type="Text/javascript">
 function countdown()
 {
      setTimeout('Decrement()', 1000);
    }
</style>
in head section.


I am want to call javascript function from code behind...

I am using this code but it is showing cannot convert void into string..

ClientScript.RegisterStartupScript(GetType(), "hwa", "<script type="text/javascript">countdown();</script>", true);

Please help me..
Danasegarane Arunachalam replied to Nitish Gupta on 10-Sep-12 07:39 AM
There are few points you missed out

1. You are using the style tag, not script tag. Your code should be

<script type="text/javascript">
 function countdown()
 {
    setTimeout('Decrement()', 1000);
    }
</script >


2. And you are missing the ; after Decrement() call and the modified code is
<script type="text/javascript">
 function countdown()
 {
    setTimeout('Decrement();', 1000);
    }
</script >
Peter Bromberg replied to Nitish Gupta on 10-Sep-12 11:26 AM
You need a SCRIPT block, not a "STYLE" block:

<script type="Text/javascript">
 function countdown()
 {
    setTimeout('Decrement()', 1000);
    }
</script>
 in head section.