c# - Add JavaScript code to View dynamically -


i have code display google map. in controller, create javascript:

mapcode = string.format("<script type='text/javascript'>init_map('my_map', {0}, {1}, 20)</script>", location.location.coordinate.latitude, location.location.coordinate.longitude) 

but can't write view:

@model.mapcode

because displays actual javascript - doesn't execute it.

is there way this?

you pass location.location model , on view:

<script type='text/javascript'>init_map('my_map', '@model.coordinate.latitude', '@model.coordinate.longitude', 20)</script> 

in manner don't have build script controller, not idea.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -