Mark Zukerman
Mark Zukerman

Reputation: 55

Set Hyperlink to be open in new window / new tab server side

I wonder if I can get some help, I'm creating hyperlink on the server side for each row in the my grid. The issue is how can I set it up to open in a new window or new tab when clicking on the hyperlink. Please help me to modify my code so it can be open in new window/new tab.

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

Upvotes: 0

Views: 1325

Answers (3)

HaveNoDisplayName
HaveNoDisplayName

Reputation: 8497

just add the target='_blank' property to anchor <a> tag under your output varriable.

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

Upvotes: -2

Jak Hammond
Jak Hammond

Reputation: 1500

It looks like you might want to set the 'target' attribute of the hyperlink, although going from what you've written so far, I'm not 100% sure where this hyperlink is going to eventually be clicked, most modern browsers, unless the user has explicitly set the behavior as otherwise would open in a new tab I think.

Either way, this might help you http://www.w3schools.com/html/html_links.asp

Upvotes: 1

user2095880
user2095880

Reputation:

Change:

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

to:

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

Source: W3 Schools

Upvotes: 2

Related Questions