Launch JavaScript function from HTML div where function name is generated dynamically ASP.NET

32 views Asked by At

I generate javascript function name dynamically like this:

<script>
        function mouseOver<%= [email protected] %>() {
            //do stuff;
        }
</script>

And later I need to launch this function from html, but nothing happens:

<div onmouseover='mouseOver" + [email protected] +"()' />

I guess I am calling it in wrong way. BTW, the @special.ObjectId is a number taken from Model and it is not null. How can I call the function here?

1

There are 1 answers

2
Sayyad Baji Shaik On

When we have the similar problem, we followed this way to invoke dynamic script.

<script>
function mouseOver(id) {
        //do stuff;
}
</script>

<div onmouseover='mouseOver(" + [email protected] +")' />

Hope this helps.!