Open new tab on HTML Anchor link click

Last Reply one year ago By dharmendr

Posted one year ago

I have this code beloq i use to open a profile in another pge by clicking the link, but i want it to open in a new tab instead of the current tab

<a class="" href='<%#getUserHREF1(Container.DataItem)%>' >
    <img src='<%#getSRC(Container.DataItem)%>' class=" img-circle animated fadeInDown" style="width:45px; height:45px" />
</a>

 

public string getSRC(object sURL)
{
    DataRowView dRView = (DataRowView)sURL;
    string Id = dRView["UserName"].ToString();
    return ResolveUrl("~/MyProfile.aspx?Id=" + Id);
} 
Posted one year ago

Hi micah,

To open in new tab you should add the target attribute in the anchor tag with the value _blank.

Refer below example.

<a class="" target="_blank" href='https://www.aspsnippets.com/'>
    <img src="https://i.imgur.com/73e8Dja.png" class="img-circle animated fadeInDown"
        style="width: 45px; height: 45px" />
</a>

Demo