Friday, March 9, 2012

ASPX Hyperlinks: Opening automatically and in New Windows

Here's a couple quick tips that took me some time to work out.

1. Opening a Hyperlink in a new window:

ASPX


<asp:HyperLink ID="jiraLink" 
runat="server">&nbsp;&nbsp;&nbsp;&nbsp;Click here to Expand Window </asp:HyperLink>

Code-behind:


String jiraURL = "http://" + jiraServerURL +"/jira/secure/IssueNavigator.jspa?sId=" + sessionGUID;
jiraLink.NavigateUrl = jiraURL;
jiraLink.Target = "_blank";



And, to automatically open a Hyperlink, put this in the Page_Load:


Response.Write("<script type='text/javascript'>window.open('" + serverURL+ "','_blank');</script>");