无法将图像作为链接

时间:2017-01-12 04:01:41

标签: c# html asp.net hyperlink

我正在使用.button-panel { z-index: 1000; opacity: 0.85; width: 76px; right: 80px; bottom: 128px; position: absolute; } 控件生成图像作为链接。

下面是aspx代码和C#代码。

asp:Hyperlink

C#

<asp:HyperLink ID="mainInteractiveFileLink" runat="server">
</asp:HyperLink>

我想将图片作为链接。我尝试了其他选项,例如mainInteractiveFileLink.NavigateUrl = thisMainInteractiveItem.linkURL; mainInteractiveFileLink.ImageUrl = thisMainInteractiveItem.imageFile; <a> HTML控件和<image>

1 个答案:

答案 0 :(得分:0)

将图片包裹在超链接控件下:

ASPX代码:

<asp:HyperLink ID="mainInteractiveFileLink" runat="server">
  <asp:image id="img" runat="server" />
</asp:Hyperlink>

代码背后:

HyperLink1.NavigateUrl = "http://www.google.com";
HyperLink1.ImageUrl = "http://assets.fodors.com/destinations/2869/tower-bridge-london-england_main.jpg";

并生成HTML:

<a id="mainInteractiveFileLink" href="http://www.google.com">
<img src="http://assets.fodors.com/destinations/2869/tower-bridge-london-england_main.jpg" >
</a>

根据您的代码,您将在图像控件上生成linkURL。

相关问题