put in whatever you want, also -6ren">
gpt4 book ai didi

asp.net-mvc - ASP.NET MVC : How to image map?

转载 作者:行者123 更新时间:2023-12-02 06:45:17 25 4
gpt4 key购买 nike

我如何在 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 发送参数,但这是处理它的实际方式吗?

谢谢

最佳答案

您必须自己创建 HTML...查看在经典 asp.net 中呈现的 html,使用:

<map id='headerMap'>
<area shape='rect' href="Default.aspx" coords='300,18,673,109' />
</map>

然后在您自己的 asp.net mvc View 中模拟,用您的 Url.RouteUrl 调用替换 map 的任何 href。

例如

<map id="mymap" name="mymap">
<area href="<%= Url.RouteUrl("MyRoute", new { param1 = "foo", param2 = 5 }) %>" alt="HTML and CSS Reference" shape="rect" coords="5,5,95,195">
<area href="<%= Url.RouteUrl("MyRoute", new { param1 = "bar", param2 = 3 }) %>" alt="Design Guide" shape="rect" coords="105,5,195,195">
</map>
<image src="sitemap.gif" alt="Site map" "usemap"="#mymap" width="300" height="200">

查看不同的 Url.RouteUrl() 重载和/或 UrlHelper 方法,看看哪一个最适合您的情况。

一旦您解决了这个问题,我的建议是将区域链接的创建封装到 HtmlHelper 扩展中。

关于asp.net-mvc - ASP.NET MVC : How to image map?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1355677/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com