I've been looking for a way to create an image map in ASP.NET MVC 3 and so far I didn't found. What I want is quite simple:
<img src="#Url.Content("~/Content/images/minasmapa.png")" usemap="minasMap"/>
<map name="minasMap">
<area shape="circle" href="" coords="249,346,9" />
<area shape="circle" href="http://" coords="433,392,8" />
</map>
The problem is: how to put an action link inside the href? What I want is to put something like an action link instead of creating the url myself, because this way I have no problem with servers.
I found this solution, but it used Url.RouteUrl, and I couldn't understand how this worked.
Just found it ... you just have to insert #Url.Action("PlantInfo","PowerPlant",new {id = "1"}) inside the href.
You can also try the example provided in this article. This allows you to construct an imagemap using c#, both in the view / controller / elsewhere.
http://www.avantprime.com/articles/view-article/9/asp.net-mvc-image-map-helper
Related
I'm new to MVC 3 and still learning. I'm currently building a static 2 page website which has a different image on both pages but are located in the same place. I have been told that I can use the ViewBag to change this image depending on what page I am on, however I have not got a clue where to begin with applying this to my website.
Any help will be greatly appreciated. Thank You for your time.
On your controller's Action method,make ViewBag or ViewData like this
ViewBag.Imagename="nameofimage";
ViewData["img"]="nameofimage";
On your view, you can make img tag like this
<img src="#ViewBag.Imagename">
or if you have created ViewData
<img src="#ViewData["img"]">
For some reason, it did not work for me when I simply tried using
#ViewBag.BackgroundImage = "~/Content/images/image.jpg"
...
<img src="#ViewBag.BackgroundImage" />
But what did work for me was
#ViewBag.BackgroundImage = "image.jpg"
...
<img src = "~/Content/images/#(ViewBag.BackgroundImage)" />
personally i dont like specifying anything view related in controller, i am using naming convention between action method names and images:
<img src="~/Content/images/#(ViewContext.RouteData.Values["action"].ToString().ToLower())_img.jpg">
and picture name for index action method would be "index_img.jpg"
For those who want use full path in viewbag, use this
#ViewBag.BackgroundImage = "Content/images/image.jpg"
...
<img src="~/#ViewBag.BackgroundImage" />
The reason why hallordylo example not working with full path is missing "~/" in src="..." and this sign "~/" should not be inside ViewBag.
I have installed the image-map plugin for Tiny MCE in Joomla 2.5.
It appears to be working alright in the backend. I have inserted an image in the article and created image map tags using the plugin button.
The tags for image map appears to be correct
But when I am browsing in the front-end there seems to be no effect for the image map. Firebug shows the line image map area as disabled.
<p>
<img border="0" title="Ground Floor" src="/images/ground-floor.jpg">
<map id="imgmap2012831174531" name="imgmap2012831174531">
<area target="_blank" href="/mywebsolutions.co.in" coords="212,934,294,1058" alt="MYWEB SOLUTIONS" shape="rect">
</map>
The line with
<area target..... appears faded.
</p>
I have tried everything including installing a jquery no conflict plugin.
<object data="images/sampledata/fruitshop/map.png" usemap="#map" border="0">
</object>
<map id="map" name="Map">
Map id should be same to usemap id.
You have to given the src in object tag. Then it will works fine..
All the best....
area tag must be closed properly like,
<area target="_blank" href="/mywebsolutions.co.in" coords="212,934,294,1058" alt="MYWEB SOLUTIONS" shape="rect" />
or
<area target="_blank" href="/mywebsolutions.co.in" coords="212,934,294,1058" alt="MYWEB SOLUTIONS" shape="rect"></area>
One more thing you should not use TineMCE for this function, select CodeMirror or None in site setting, it will definitely work. after saving particular post you can change back to tineMCE. Remember not to edit same on TinyMCE in future, else it will remove your functionality.
In a JSP page, I need to have an absolute URL of on of my page in order to do some integration with twitter.
This is what I have
<spring:url value="/blog/article1" var="articleUrl" />
<spring:url value="https://twitter.com/share" var="twitter" >
<spring:param name="url" value="${articleUrl}"/>
</spring:url>
Tweet
My problem is that it generates :
Tweet
And of course, twitter do not like relative URL...
Is there a simple way to have the absolute URL (with spring:url or c:url or other...)?
Try to explore more about context attribute in <spring:url/> tag. I think it would be helpful to you.
Hope this helps you. Cheers.
I found my response on StackOverflow :
<c:set var="baseURL" value="${fn:replace(pageContext.request.requestURL, pageContext.request.requestURI, pageContext.request.contextPath)}" />
I wondered if it is possible to show picture in a view without calling an action. The picture is displayed by using the following Razor code:
<img class="photo" src="#Url.Action("GetImage", "Home", new { id = #Model.Id })" />
But retrieving picture from server requires an additional request.
Is it possible to "deploy" image in ViewBag and show it in view without calling server?
Thanks,
Is it possible to "deploy" image in ViewBag and show it in view without calling server?
You could use the Data URI scheme. But be careful as it might not be supported by all browsers.
Example:
<img class="photo" src="data:image/png;base64,iVBORw0KG....." alt="" />
where src attribute of the image contains the Base64 encoded image that could come from ViewBag or a view model.
Hi I am using http://code.google.com/apis/chart/docs/gallery/googleometer_chart.html
I have:
<img src="http://chart.apis.google.com/chart?cht=bvg&chs=250x150&chd=s:egbdf&chxt=x,y&chxs=0,ff0000,12,0,lt|1,0000ff,10,1,lt&chm=o,000000,0,-1,10|V,000000,0,-1,1:15,,:4:10|H,000000,0,-1,3:9,,:8:17&chxl=0:|E|G|B|D|F" usemap ="#chart" />
<map name='chart'>
<area name='bar0_0' shape='POLY' coords= '124,440,124,499,143,440,143,498' href='#'>
<area name='bar0_1' shape='RECT' coords='55,129,78,63' href='#'>
</map>
When I use 'rect' for shape I can attach a click event etc but when I use 'poly' It doesn't work.
I've use a jQuery mouse position plug in to check the coords and they seem ok.
Can anyone help please?
Thanks
put image into something like paint and get it's coordinates, not the coordinates on the web page Obviosuly, so it will still work anywhere on the page.