Link to home
Start Free TrialLog in
Avatar of R8VI
R8VI

asked on

how to call c# method in javascript

Hi,

I have the following method in c#

public void logout()
        {
          
        

        }

Open in new window


and the following code in javascript

<script type="text/javascript">
    window.onunload = function unloadEvent() {
    <%logout()%> ; 
        
    }           
</script>

which gets called like so 

<body onbeforeunload="unloadEvent()">

But i get the following error 
 CS1002: ; expected

Line 8:  <script type="text/javascript">
Line 9:      window.onunload = function unloadEvent() {
Line 10:     <%logout()%> ; 
Line 11:         
Line 12:     }   

please help 

Thanks,

R8VI 

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of sachinpatil10d
sachinpatil10d
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
In your code just change this

<%logout()%> ;

to

<%logout();%>