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")'" />
To solve the "Unterminated string constant" error, make sure to enclose your strings in quotes consistently. String literals must be enclosed in single quotes, double quotes or backticks. When writing a multiline string use backticks.
"unterminated string literal" means that somewhere a string variable is opened by not closed properly, either because of un-escaped character in it, or a line break, or something like that.
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")
+ "'")" />
Use an actionlink instead. This one creates a nice bootstrap button:
@Html.ActionLink("Cancel", "Index", "Home", null, new { @class = "btn btn-default" })
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With