How to open/popup a seperate IE window

J

Jeff User

Hello all
I am working on creating a Web application
I am using C# code behind
..NET1.1

Rather than navigate to a new window, I want to open a seperate IE
window when the user clicks a button. Addionally, I want to send a
(query ?) string to the window to be displayed. This will be used to
display additional information for the user to see while still on the
same page.

I thought this would be a common issue, but I do not see any
discussion of it that provides any answers or code.

Thanks everyone

Jeff
 
J

Jon

You need to use javascript to open a new window. ASP.Net is server side.

You can do something like this on the page to place javascript to execute on
load or you could add an onlick event to the button control with the
javascript popup code
Page.RegisterStartupScript("PopMsg", "<script language=javascript>alert('" +
PopMessage + "');</script>")
 
N

Norman Yuan

Yes, it is common issue, if you have ever done some client-side script.
Server-side code cannot, or is not allowed to, open new browser window.

Typically, you can emit client script code in your ASP.NET code. Here is an
simple example:

private void Page_Load(....)
{
if (!Page.IsPostBack)
{
//Some code...your querystring value may have to be generated
dynamically

string queryString1=SomeProcess1();
string queryString2=SomeProcess2();

Button1.Attributes.Add("onclick","OpenNewWindow('AnotherPage.aspx?aaa="
+ queryString1 + "&bbb=" + queryString2 + "');");
}
}

Then, on the page's HTML view, add this javaScript function into
<Head></Head>section

function OpenNewWindow(target)
{
var
win=window.open(target,"TheNewWindow","height=500,width=500,menubar=0");
win.focus();
}
 
J

Jeff User

Thanks
This is very close.
I got the script to work, but now, instead of adding the onClick
attribute to a button, instead of that line, can I somehow add those
settings to the Client side "onload" event?

This way I can control when it happens from within my C# code.

I tried typing Page.
but intellisense does not show me an "Attributes" to add to for the
page. I know I could put this in the <body onload="function"> but then
it would load all the time. thats not good.

Thanks again.
Jeff
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Make the body tag a server tag:

<body id="Body" runat="server">

Declare the reference to the tag in code behind:

protected HtmlGenericControl Body;

Now you can use the Attributes property to add onload to the tag.
 
C

Cor Ligthert [MVP]

Jeff,

Yes this was common practise, be aware that there are a lot of popup killers
now going around which prevent that there is an extra window opened from
javascript.

You can as well create a little panel on your normal page that looks like a
popup and ask the user to enter information. (What is very much easier to do
in ASPNET).

Cor
 
C

Cor Ligthert [MVP]

Jon,

Therefore is not so much sample needed, drag a panel on your form and start
to put other controls on that. Than you can make it visible and hide it any
time you want in your code.

By instance panel1.visible = false 'or true

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

WebBrowser and Popup window 3
how to open up messages in seperate window? 1
POPUP IE WINDOW 2
popup window in asp.net 1
Keep a Popup window open 5
Popup window 2
Popup Window 2
popup IE window from outlook 12.0 1

Top