i am developing a webform in which there is a preview button.On
pressing the button, I have to open a new window and display another
aspx page there.Can anyone tell me how to do it? Response.redirect
opens the new page in the same window.
AkshayThere is no way to make ASP.NET open a new browser window. You can, however,
include dynamically generated Javascript code to open a new window with the
desired URL. The necessary information can be passed to this window using
whatever technique you want, including querystring, Session, etc. Opening
new windows is performed by the browser, so ASP.NET has no control over it.
However, keep in mind that many browsers have pop-up blockers that may
prevent Javascript from opening this new window (it will usually inform the
user and give them the option of opening it, but it waits for the user's
confirmation, so you should tell them why the browser will be trying to open
a new window). Good Luck!
--
Nathan Sokalski
njsokalski@.hotmail.com
http://www.nathansokalski.com/
"akki" <akshay.katrekar@.gmail.com> wrote in message
news:1139715554.477654.293140@.o13g2000cwo.googlegroups.com...
>i am developing a webform in which there is a preview button.On
> pressing the button, I have to open a new window and display another
> aspx page there.Can anyone tell me how to do it? Response.redirect
> opens the new page in the same window.
> Akshay
>
Hi Akshay,
Here's a page in ASP.NET 2.0 that shows one way to accomplish what you need.
Let us know if it helps?
Ken
Microsoft MVP [ASP.NET[
<%@. Page Language="VB" %>
<script runat="server">
Protected Sub Button1_Click _
(ByVal sender As Object, ByVal e As System.EventArgs)
ClientScript.RegisterStartupScript _
(Me.GetType, "popup", "window.open('" & _
TextBox1.Text & "','_blank','menubar=no')", True)
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Popup Demo</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:textbox id="TextBox1"
runat="server">http://www.kencox.ca/</asp:textbox><br />
<asp:button id="Button1" runat="server" onclick="Button1_Click"
text="Open" /> </div>
</form>
</body>
</html>
"akki" <akshay.katrekar@.gmail.com> wrote in message
news:1139715554.477654.293140@.o13g2000cwo.googlegroups.com...
>i am developing a webform in which there is a preview button.On
> pressing the button, I have to open a new window and display another
> aspx page there.Can anyone tell me how to do it? Response.redirect
> opens the new page in the same window.
> Akshay
>
Thursday, March 22, 2012
open a new window from code behind
Labels:
anotheraspx,
asp,
button,
code,
developing,
display,
net,
onpressing,
page,
preview,
webform,
window
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment