开发者

Access C# code from .JS javascript file

I am trying to put a c# code when a js function happens. I found this article https://www-archive.mozilla.org/js/spidermonkey/tutorial.html but I didn't fully understand how to do it in my case. Here is what I tried.

rooms.aspx

    <script type="text/javascript" language="Javascript">

    function DetectBrowserExit() 
    {
//        alert('Execute task which do you want before exit');
        <%
        if(Application["player1"]==Session["mynick"])
        {
            Application["player1"]="";
            Application["status1"]=false;
        } 
        %>

    }

    window.onbeforeunload = function () { DetectBrowserExit(); }

</script>

All that goes in the head of the as开发者_StackOverflow中文版px and DetectBrowserExit happens when a user closed the browser.

You know how to make the C# code accessible?

Thank you.


You can use page methods with a script manager to do this.

Using Page Methods in ASP.NET AJAX

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜