asp.net的MVC:如何影像地图? [英] asp.net mvc: How to image map?

查看:189
本文介绍了asp.net的MVC:如何影像地图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ASP.NET MVC如何构建一个影像地图?对于REF:

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>

很抱歉,如果这是多余的。我的研究表明,这可能是一个版本2 MVC答案。寻找类似Html.ActionLink如果它存在的东西。很显然,我可以通过名称引用路线和使用Url.RouteUrl在参数发送,但这是处理它的事实上的方式?

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?

感谢

推荐答案

您需要创建自己的HTML ...看看是用经典的asp.net呈现HTML:

You'll have to create the HTML yourself... have a look at the html that is render in classic asp.net using:

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

然后模仿,在你自己的asp.net MVC视图替换任何的HREFs的与您的通话Url.RouteUrl地图。

Then mimic that in your own asp.net mvc view replacing any of the hrefs for the map with your Url.RouteUrl calls.

例如

<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方法,看看哪一个适合您的情况最好的。

Have a look at the different Url.RouteUrl() overloads and/or UrlHelper methods to see which one suits your situation the best.

一旦你整理了这一点,我的建议是要封装面积链接的创建成的HtmlHelper扩展。尼斯和干净的那种方式: - )

Once you've sorted that out, my recommendation would be to encapsulate the creation of you area links into a HtmlHelper extension. Nice and clean that way :-)



查尔斯

HTHs
Charles

这篇关于asp.net的MVC:如何影像地图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆