Mvc UrlHelper 与 JQuery 模板结合使用
我想将 Mvc UrlHelper 与 JQuery 模板结合使用。
示例模板...
...
{{each Items}}
<div>
<%= Url.Action("Action", "Controller", new { Id = "${$value.Id}" })%>
</div>
{{/each}}
...
Url 帮助器 Action 方法对我作为 Id 参数传入的模板占位符进行编码。这呈现为..
...
<div>
/web/controller/%24%7B%24value.Id%7D/action
</div>
<div>
/web/controller/%24%7B%24value.Id%7D/action
</div>
...
我确实可以采取一种方法来阻止 Action 方法对 Id 参数值进行编码,但我认为它只是完成了它的工作!
I would like to use the Mvc UrlHelper in conjunction with JQuery Templates.
Example template...
...
{{each Items}}
<div>
<%= Url.Action("Action", "Controller", new { Id = "${$value.Id}" })%>
</div>
{{/each}}
...
The Url helper Action method encodes the template placeholder that I pass in as the Id parameter. This renders as..
...
<div>
/web/controller/%24%7B%24value.Id%7D/action
</div>
<div>
/web/controller/%24%7B%24value.Id%7D/action
</div>
...
I could really do with a way to prevent the Action method from encoding the Id parameter value, but I suppose it’s only doing its job!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,这是设计使然,您必须解决它 - 请参阅 Rick Strahl 的帖子
http ://west-wind.com/weblog/posts/831885.aspx
unfortunately its by design and you'll have to work around it - see Rick Strahl's post on this
http://west-wind.com/weblog/posts/831885.aspx