Thursday, March 22, 2012

Open a page in a new window

How do you open a page in a new window? It seems like it should be easy but I don't know how to do it, unless its from a link.

During the SelectedIndexChange event of a dropdownlist I'd like to open a related page in a new window, but can't figure out how to do it. :(

I basically want this to open in a new window instead of the one it is called from:

Response.Redirect(fpath)Hi,
Instead of Response.Redirect use this

<% ' your asp code here
'Response.Redirect(page.aspx) 'Dont use this
%>
<script>
window.open("page.aspx");
</script>
<% Response.End %>
But how would I fire that from a button press or inside a SelectedIndexChanged event?
You couldnt - unless you input that script into the innerhtml of a <span runat=server > Tag - if you go this route you have to put the span at the bottom of the page and change the inner html in the SelectedIndexChanged event

OR

you could just go ahend and use cleint script all the way -
using the onclick event or onchange event of a HTML control (or select or input tag>

something like this
Ex.

<head>
<sciript Language=javascript>

function RunMe
{

window.open(window.myform.myfield.value)
}
</script>

</head>

<input id=myfield onclick=Javascript:runme>
In a nutshell there - I would tend to just stick with client javascript, when doing that.

0 comments:

Post a Comment