views:

479

answers:

1

I have some script type="javascript"/script tags inside both a repeater and a for loop in mvc.

On page render the script is gone and is not displayed both inside the repeater and the for loop (they are separate).

Is there some option I need to set to stop this from happening? Has anyone had this happen to them?

A: 

Based on url: http://stackoverflow.com/questions/455912/script-script-inside-a-repeater-control-code-not-showing-up-in-the-source-code you are injecting the javascript into the repeater using the code behind.

For testing purposes, can you try placing your script tags within the ItemTemplate?

My second suggestion would be to pass the values required to construct the javascript as part of your datasource and then output them as part of your template:

<script type="text/javascript">
 AudioPlayer.embed('<%#DataBinder.Eval(Container.DataItem, "ID")%>', {soundFile: '<%#DataBinder.Eval(Container.DataItem, "Url")%>'});
</script>

Regards

Gavin

Gavin