asp.net mvc:如何进行图像映射?
如何在 ASP.NET MVC 中构建图像映射?供参考:
<map id='headerMap'>
<area shape='rect' href="Default.aspx" coords='300,18,673,109' />
</map>
markus 的一个不相关问题的答案的一个答案是类似的:
<a href="<%= Url.RouteUrl("MyRoute", new { param1 = "bla", param2 = 5 }) %>">
put in <span>whatever</span> you want, also <img src="a.gif" alt="images" />.
</a>
抱歉,如果这是多余的。我的研究表明这可能是版本 2 mvc 答案。寻找类似于 Html.ActionLink 的内容(如果存在)。显然,我可以按名称引用路由并使用 Url.RouteUrl 发送参数,但这是处理它的事实上的方法吗?
谢谢
How in ASP.NET MVC would I construct an image map? For ref:
<map id='headerMap'>
<area shape='rect' href="Default.aspx" coords='300,18,673,109' />
</map>
One answer of an answer of an unrelated question by markus is something similar:
<a href="<%= Url.RouteUrl("MyRoute", new { param1 = "bla", param2 = 5 }) %>">
put in <span>whatever</span> you want, also <img src="a.gif" alt="images" />.
</a>
Sorry if this is redundant. My research indicated that this may be a version 2 mvc answer. Looking for something similar to Html.ActionLink if it exists. Obviously, I could reference the route by name and send in the parameters using that Url.RouteUrl, but is this the defacto way to handle it?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您必须自己创建 HTML...查看在经典 asp.net 中渲染的 html,使用:
然后在您自己的 asp.net mvc 视图中模仿,用您的 Url 替换地图的任何 href .RouteUrl 调用。
例如,
查看不同的 Url.RouteUrl() 重载和/或 UrlHelper 方法,看看哪一个最适合您的情况。
一旦您解决了这个问题,我的建议是将区域链接的创建封装到 HtmlHelper 扩展中。
You'll have to create the HTML yourself... have a look at the html that is render in classic asp.net using:
Then mimic that in your own asp.net mvc view replacing any of the hrefs for the map with your Url.RouteUrl calls.
E.g.
Have a look at the different Url.RouteUrl() overloads and/or UrlHelper methods to see which one suits your situation the best.
Once you've sorted that out, my recommendation would be to encapsulate the creation of you area links into a HtmlHelper extension.
我可以替换以下内容并且效果很好:
html example:
mvc4 example
I was able to substitute the following and it worked just fine:
html example:
mvc4 example
另一种选择是使用 C# 构建图像映射。以下链接提供了一些帮助程序方法,可从视图/控制器中的代码创建图像映射:
http://www.avantprime.com/articles/view-article/9/asp.net-mvc-image-map-helper
编辑:尝试http://web.archive.org/web/20110728032820/http://www.avantprime.com/articles/view-article/9/asp.net-mvc-image -map-helper 获取原始链接的存档版本。
Another option is to construct your image map with c#. The following link provides some helper methods that creates an image map from code within your view / controller:
http://www.avantprime.com/articles/view-article/9/asp.net-mvc-image-map-helper
Edit: Try http://web.archive.org/web/20110728032820/http://www.avantprime.com/articles/view-article/9/asp.net-mvc-image-map-helper for an archived version of the original link.