[英]How to hyperlink an image in asp.net (C# / vb.net)?
I have a webpage in which I am trying to hyperlink an image. 我有一个网页,试图在其中超链接图像。 The screenshot of that section of the webpage is as follows:
该页面的该屏幕截图如下:
On clicking the pdf image, it should open a pdf. 在单击pdf图像时,应打开一个pdf。
At this moment, I am able to create a pdf image
which is local to my machine. 目前,我可以创建本地机器上的
pdf image
。
The code in .aspx file are: .aspx文件中的代码是:
<div class="row" id="divViewAssessment" runat="server">
<div class="itemtitle">
<asp:Label ID="litBlankAssessment" runat="server"></asp:Label>
</div>
<div class="itemdata">
<asp:ImageButton ID="btnViewAssessment" runat="server" ImageUrl="~/Images/doc_pdf.gif"
CausesValidation="False" ValidationGroup="vgrp1" Enabled="true"></asp:ImageButton>
</div>
</div>
I am wondering what code do I need to put in .aspx.vb
file ? 我想知道我需要在
.aspx.vb
文件中放入什么代码? I am sure what I need to put in .aspx
but not sure what need to put in .aspx.vb (behind the code)
. 我确定我需要在
.aspx
放什么,但是不确定在.aspx.vb (behind the code)
要放什么.aspx.vb (behind the code)
。
The path of the pdf local to my machine is "~/Licensee/" + CStr(Session("LicenseeCode")) + "/ViewSA/Lebanon Primary Care Standards for SW.pdf"
The LicenseeCode is MPHLB
. 在我的计算机上本地的pdf路径为
"~/Licensee/" + CStr(Session("LicenseeCode")) + "/ViewSA/Lebanon Primary Care Standards for SW.pdf"
为MPHLB
。
The ImageButton
control is intended for triggering a postback, not navigating to a URL. ImageButton
控件用于触发回发,而不是导航到URL。
Use a HyperLink
control instead. 请改用
HyperLink
控件。 It has an ImageUrl
property to set the image that is displayed, and also a NavigateUrl
property to set your target URL. 它具有
ImageUrl
属性来设置显示的图像,还具有NavigateUrl
属性来设置目标URL。
You can use the following code.. 您可以使用以下代码。
Protected Sub btnViewAssessment_Click(sender As Object, e As ImageClickEventArgs) Handles btnViewAssessment.Click
Response.Redirect("Lebanon Primary Care Standards for SW.pdf")
End Sub
Put your pdf in solution folder. 将您的pdf放入解决方案文件夹中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.