当我尝试通过 JS 访问 ViewData 时出现编译错误
ViewData["results"] = indication.Model.prepaymentList;
return View(@"~\Views\Indications\TermSheetViews\Swap\PrePayment.aspx", indication.Model);
这工作正常,但我的编译错误发生在这一行的视图上:
var prepaymentList = <%= ViewData["results"]; %>;
出了什么问题?
ViewData["results"] = indication.Model.prepaymentList;
return View(@"~\Views\Indications\TermSheetViews\Swap\PrePayment.aspx", indication.Model);
This works fine but my compilation error is happening on the view on this line:
var prepaymentList = <%= ViewData["results"]; %>;
What's wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的
;
太多。应该是:当然写这样的东西绝对没有任何意义。
您可能需要:
这当然会导致另一个问题,即 ViewData 的使用。我建议您使用强类型视图和模型,以便最终您拥有:
You have too many
;
. It should be:Of course writing something like this makes absolutely no sense whatsoever.
You probably need:
Which of course leads to another problem which is the usage of
ViewData
. I would recommend you using a strongly typed view and model so that finally you have:快速猜测:尝试在
]
之后删除;
A quick guess: try removing
;
after]