Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Imagebutton Open New Browser Window

Status
Not open for further replies.

nevets2001uk

IS-IT--Management
Joined
Jun 26, 2002
Messages
609
Location
GB
Hi,

I've been trying to figure something out all afternoon and have finally accepted that I need help. I have an imageButton on one of my aspx pages which when clicked uses a Select Case statement to redirect to 1 of 3 new pages depending on some variables. This works without a problem but what I'd like to do is have the new page open in a new window.

I can do this with a normal link and a bit of javascript but not sure how to do it on the click event of the imagebutton in the codebehind.

Any suggestions?

Cheers

Steve G (MCP)
 
I'm not sure, but I think you are going to have to pass down the required javascript to open the new window, so that it executes when the document is loaded.

Mark [openup]
 
From a datagrid item template is where this is used.
Code:
	Sub openImage(sender As Object, e As System.Web.UI.ImageClickEventArgs)
		openPage2(MasterGrid.DataKeys(MasterGrid.SelectedIndex))
	End Sub
	
    Sub openPage2(strID As String)
    	Dim link As String = "'[URL unfurl="true"]http://web/admin/details.aspx?printID="[/URL] & strID & "',""""" & ",""HEIGHT=520,WIDTH=800,scrollbars=yes"""
   	    Dim strjs as string = "<script language='javascript'>window.open(" & link & ")</script>"
		Literal1.Text = strjs
	End Sub
add this to html wherever you want
Code:
<asp:imageButton onClick=openImage runat=server ImageUrl="img/printer.gif" toolTip="Print this Incident" CausesValidation=False />
<asp:Literal id="Literal1" runat="server" />
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top