【发布时间】:2016-11-11 03:13:38
【问题描述】:
我正在尝试为链接设置标签以打开图像。 我在后面的代码中使用 asp.net 来做到这一点:
lblFile1.Text = "<a href=\"/utilities/ViewPDF.aspx?ImageName=" + ConfigurationManager.AppSettings["Logo2ImageFolder"] + Company.Current.CompCode + "\\" + f.File1 + "\" target=\"blank\">View File</a>";
但现在我需要将其更改为 JavaScript,因此当他们单击链接标签时,它会打开链接。
我试过了,但标签甚至不显示:
document.getElementById('lblFile1').value = "<a href=\"/utilities/ViewPDF.aspx?ImageName= + ConfigurationManager.AppSettings['Logo2ImageFolder'] + Company.Current.CompCode + '\\' + " + result.File1 + "\" target=\"blank\">View File</a>";
我正在使用<asp:Label runat="server" ID="lblFile1"></asp:Label>
当我在后面的代码中使用该链接时,该链接确实有效,但在 JavaScript 中无效。
【问题讨论】:
-
当你的 javascript 运行时你收到了什么输出?
-
我认为这会对你有所帮助。像这样使用 id 。
-
@PravinTukadiya 做出的改变没有奏效
-
@SunilKumar 输出什么? result.File1 等于文件名
标签: javascript jquery asp.net label href