如何在新的浏览器标签中打开图像?

时间:2021-03-28 21:16:34

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

我正在尝试在新的brrowser标签页中打开一个图片,如下所示:

<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?

我只需要显示一个图像,什么都不显示(没有样式等等)href呢?我需要什么?

1 个解决方案

#1


2  

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

将href属性更改为图像的URL,您可以这样做:

<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.

编辑:如果您正在从数据库检索图像,那么您将需要Url。行动而不是Url.Content。请查看这个问题,以进行类似的关于从数据库检索图像的讨论。

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

编辑#2:更新示例代码以使用Url。行动而不是Url.Content

#1


2  

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

将href属性更改为图像的URL,您可以这样做:

<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.

编辑:如果您正在从数据库检索图像,那么您将需要Url。行动而不是Url.Content。请查看这个问题,以进行类似的关于从数据库检索图像的讨论。

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

编辑#2:更新示例代码以使用Url。行动而不是Url.Content