You CANNOT open a new client window from a server side function. You need
to use client-side script to do this.
Your server function can render a javascript function that gets called when
the page reloads, but that causes an uncessary post back, best to do it from
the client side in the first place...
<script language="javascript">
<!--
function openPage(sURL)
{
var winWidth = screen.width;
var winHeight = screen.height - 100;
var winProps = "resizable=no, toolbar=no, scrollbars=yes,
menubar=no,
location=no, status=yes, top=0, left=0, width=" + winWidth + ", height=" +
winHeight;
window.open(sURL,"_blank",winProps, true);
return true;
}
//-->
</script>
You then call the function by adding a click event to a standard HTML button
like so...
<INPUT onclick="openPage('./Hello.aspx');" type="button" value="Open Page in
New Browser">
HTH,
Dean Fiala
-----------------------------
Very Practical Software, Inc.
http://www.vpsw.com/links.aspx
-----Original Message-----
From: Mustafa Ali Bamboat [mailto:[EMAIL PROTECTED]
Sent: Thursday, May 20, 2004 3:58 PM
To: [EMAIL PROTECTED]
Subject: [AspNetAnyQuestionIsOk] How to Open a Page in the New Window
Hi Friend,
I'm trying to open a page in the New Window by using the
Response.Redirect command, but I couldn't succed. It opens a page in
the same window.
Please help me out from this problem or if you have any
suggestion/alternative of the above cited problem then please let me
know.
Here I'm also enclosing the code for your reference.
*******************************************************
Save as Buttons2.aspx
-----------------------
<[EMAIL PROTECTED] Language=VB Debug=True %>
<Script runat="server">
Sub SubmitBtn_Op(ByVal Sender as Object, ByVal E as CommandEventArgs)
If E.CommandArgument.CompareTo("OP") = 0 Then
Response.Redirect("./Hello.aspx")
End If
If E.CommandArgument.CompareTo("OPN") = 0 Then
' Response.Redirect("./Hello.aspx")
' but this time it must open in new window
lblMessage.Text = "It Must Open in New Window! But HOW ???"
End If
End Sub
</Script>
<html>
<body>
<form runat="server">
<BR>
<BR>
<BR>
<asp:Button
id="btn1"
text="Open Page"
CommandArgument = "OP"
CommandName = "Open New"
OnCommand="SubmitBtn_Op"
runat="server"
/>
<BR>
<BR>
<BR>
<asp:Button
id="bnt2"
text="Open Page in New Browser"
CommandArgument = "OPN"
CommandName = "Open New"
OnCommand="SubmitBtn_Op"
runat="server"
/>
<asp:Label
id="lblMessage"
runat="Server"
/>
<BR>
<BR>
<BR>
</form>
</body>
</html>
***************************************************
Save as Hello.aspx
-----------------------
<html>
<body>
<H1> Hello This is a Testing Page
</H1>
</body>
</html>
-----------------------------------------------
Note: I have to do this thing from a button which calls a function,
Its my project requirement and above code is the dummy one
Looking forward to your kind reply.
Regards,
Mustafa Bamboat
Yahoo! Groups Links
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Yahoo! Domains - Claim yours for only $14.70
http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/saFolB/TM
---------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/