MVC3未结束的字符串常量语法错误 [英] MVC3 unterminated string constant syntax error

查看:507
本文介绍了MVC3未结束的字符串常量语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下的code,给了我一个语法错误 - 未终止的字符串constant.I've匹配了报价似乎无法发现的问题。有任何想法吗?它工作正常,语法错误仅仅是烦人。

 <输入类型=按钮级=我的按钮值=NAME =后面的onclick =location.href ='@ Url.Action(型号.Back.Step.ToString(),myController的)'/>


解决方案

您可以把它改写如下:

 <输入类型=按钮级=我的按钮值=NAME =背
     的onclick =@(location.href ='
        + Url.Action(Model.Back.Step.ToString(),myController的)
        +')/>

I have the following code which gives me a syntax error - unterminated string constant.I've matched up the quotes can't seem to spot an issue. Any ideas? It works fine, the syntax error is just annoying.

  <input type="button" class="my-button" value="" name="back" onclick="location.href='@Url.Action(Model.Back.Step.ToString(), "MyController")'" />

解决方案

You can rewrite it like this:

<input type="button" class="my-button" value="" name="back" 
     onclick="@("location.href='" 
        + Url.Action(Model.Back.Step.ToString(), "MyController")  
        + "'")" />

这篇关于MVC3未结束的字符串常量语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆