开发者

How to open an image in a new browser tab?

开发者 https://www.devze.com 2023-02-19 05:50 出处:网络
I\'m trying to open an image in new brrowser tab like this: <a href=\"\" target=\"_blank\"> <img height=\"660px\" width=\"420px\"

I'm trying to open an image in new brrowser tab like this:

<a href="" target="_blank">
  <img height="660px" width="420px"  
   src="<%= Url.Action("WebPageImage", "WPMManagement", new { id = actualId }) %>" 
   alt="bild mit webseiten version" />
</a>

I need to show 开发者_开发技巧just an image and nothing else (no styles etc.) What about href? What do I need in it?


Change the href attribute to the URL of your image and you're good to go:

<a href='<%= Url.Action("WebPageImage", "WPMManagement", new { id = actualId }) %>' target="_blank">Click here to view the image</a>

EDIT: If you're retrieving images from the database, then you'll need Url.Action rather than Url.Content. Check out this question for a similar discussion about retrieving images from a database.

EDIT #2: Updated the example code to use Url.Action rather than Url.Content

0

精彩评论

暂无评论...
验证码 换一张
取 消