Reputation: 15378
I have error in ='@
unterminated string constant
<input class="blue" type="button" onclick="location.href='@(Url.Action("Index", "Home", Model.RouteData))';" value="Index"/>
how to solve this?
Upvotes: 2
Views: 504
Reputation: 535
<input class="blue" type="button" onclick="location.href='@(Url.Action(\"Index\", \"Home\", Model.RouteData))';" value="Index"/>
This should work. But you should really limit the usage of inline CSS/JS.
Something like this should be better.
HTML
<input id="button" class="blue" type="button" value="Index"/>
JS
document.getElementById("button").onclick= function(){
location.href='@(Url.Action("Index", "Home", Model.RouteData))';
}
Upvotes: 2
Reputation: 10020
String constants must be enclosed within a pair of quotation marks.
Try this-
<input class="blue" type="button" onclick="location.href='@(Url.Action('"Index"', '"Home"', Model.RouteData))';" value="Index"/>
Upvotes: 0