未捕获的语法错误:ASP.NET中出现意外字符串
本文关键字:NET 字符串 意外 ASP 语法 错误 | 更新日期: 2023-09-27 18:26:04
我在ASP.NET MVC 5中有这个按钮代码。
在浏览器中我得到这个错误:
未捕获的语法错误:意外的字符串
<input type="button" value="Bid for this project"
onclick="location.href'@Url.Action("Create", "Bid", new {projectid = Model.ProjectID})'" />
在浏览器中,按钮如下:
<input type="button" value="Bid for this project"
onclick="location.href'/Bid/Create?projectid=1'" />
你能告诉我如何改正吗?谢谢
字符串在href
:之后缺少赋值运算符=
<input type="button" value="Bid for this project"
onclick="location.href='@Url.Action("Create", "Bid", new {projectid = Model.ProjectID})'" />
在浏览器中:
<input type="button" value="Bid for this project" onclick="location.href='/Bid/Create?projectid=1'" />
添加后应该可以工作。
您缺少一个=
符号
<input type="button" value="Bid for this project" onclick="location.href='@Url.Action("Create", "Bid", new {projectid = Model.ProjectID})'" />
您在href
之后错过了=
<input type="button" value="Bid for this project" onclick="location.href= '@Url.Action("Create", "Bid", new {projectid = Model.ProjectID})'" />
因为正确的javascript语法是
location.href= '@Url.Action("Create", "Bid", new {projectid = Model.ProjectID})';