all groups > asp.net > april 2008 >
You're in the

asp.net

group:

Opening a new window when button clicked


Re: Opening a new window when button clicked [RESOLVED] Mark Rae [MVP]
4/24/2008 12:00:00 AM
asp.net:
[quoted text, click to view]


Or alternatively:

<asp:Button ID="btnAnotherPageLink" runat="server" Text="Another Page"
OnClientClick="window.open('../folder5/anotherpage.aspx');return false;" />

Don't forget the semi-colons at the end of each JavaScript statement...


--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Re: Opening a new window when button clicked [RESOLVED] Mark Rae [MVP]
4/24/2008 12:00:00 AM
[quoted text, click to view]

Always a pleasure, never a chore... :-)


--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Opening a new window when button clicked Jim in Arizona
4/24/2008 11:38:54 AM
When placing a link using html, it's easy to have a new window opened for
the link instead of redirecting the current page to the destination. IE:

<a href="../folder5/anotherpage.aspx" target=_blank>Another Page</a>

I've placed a button on the page that I would like to have do the same
thing:

<asp:button id="btnAnotherPageLink" runat="Server" text="Another Page" />

Protected Sub btnAnotherPageLink_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnActiveDialup.Click
Response.Redirect("../folder5/anotherpage.aspx")
End Sub

This will cause the current page to navigate to the destination page. How
can I have a new window open up and load the destination page instead?

TIA,
Jim

RE: Opening a new window when button clicked bruce barker
4/24/2008 12:13:00 PM
buttons do a form submit. you set the target on the form to control this.
asp.net forms do not allow the target to be set, so yo must use a non-server
form, or use javascript to set the target.

-- bruce (sqlwork.com)


[quoted text, click to view]
Re: Opening a new window when button clicked [RESOLVED] Jim in Arizona
4/24/2008 3:14:13 PM

[quoted text, click to view]

After some searching, I found that adding this to the Page_Load sub did the
trick:

btnAnotherPageLink.Attributes.Add("onClick",
"window.open('../folder5/anotherpage.aspx')")



Re: Opening a new window when button clicked [RESOLVED] Jim in Arizona
4/24/2008 3:43:05 PM
[quoted text, click to view]

Oh! That's helpful! Thanks Mark!

AddThis Social Bookmark Button