【问题标题】:Set Hyperlink to be open in new window / new tab server side设置超链接在新窗口/新标签服务器端打开
【发布时间】:2015-01-16 02:49:47
【问题描述】:

我想知道是否可以得到一些帮助,我正在服务器端为网格中的每一行创建超链接。 问题是如何将其设置为在单击超链接时在新窗口或新选项卡中打开。 请帮我修改我的代码,以便它可以在新窗口/新标签中打开。

Protected Function GenerateReportLink(ByVal inputVal)
        Dim output As String = ""
        Try
            Dim svcs As New SystemServices

            ' Check for null values
            If Not inputVal Is Nothing And Not String.IsNullOrEmpty(inputVal) Then

                Dim URL As String = Nothing
                URL = (String.Format("https://www.test.com/cgis/{0}/Reports/ShortReport.asp?/SessionID={1}&IncidentID={2}", m_User.CompanyCode, m_SessionID, m_IncidentCaseID.ToString()))
                output = "<a href='" + URL + "'>Report</a>"
            End If
        Catch
        End Try
        Return output
End Function

【问题讨论】:

    标签: asp.net vb.net hyperlink


    【解决方案1】:

    变化:

    output = "<a href='" + URL + "'>Report</a>"
    

    到:

    output = "<a href='" + URL + "' target='_blank'>Report</a>"
    

    来源:W3 Schools

    【讨论】:

      【解决方案2】:

      看起来您可能想要设置超链接的“目标”属性,尽管从您目前所写的内容来看,我不能 100% 确定该超链接最终会在哪里被点击,最现代的浏览器,除非用户已明确设置行为,否则我认为会在新选项卡中打开。

      无论哪种方式,这可能会对您有所帮助http://www.w3schools.com/html/html_links.asp

      【讨论】:

        【解决方案3】:

        只需将target='_blank' 属性添加到您的输出变量下的&lt;a&gt; 标记。

        "<a href='" + URL + "' target='_blank'>Report</a>"
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2014-12-12
          • 2014-10-17
          • 1970-01-01
          • 1970-01-01
          • 2014-11-05
          • 1970-01-01
          • 2013-05-28
          相关资源
          最近更新 更多