0
我試圖將我的模型屬性的值插入到javascript變量中,但它不起作用。MVC Razor into javascript issue
我試過如下:
<script type="text/javascript">
var sample = "@(Model.MyProperty)";
</script>
<script type="text/javascript">
var sample = "@Model.MyProperty";
</script>
<script type="text/javascript">
var sample = @Model.MyProperty;
</script>
<script type="text/javascript">
@{
var sample = Model.MyProperty;
}
</script>
您確定此標記無效或其他建議不干擾嗎?似乎很好。 – 2012-04-20 10:22:12