471,319 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 software developers and data experts.

window.open v.s. asp.net

Hi there,

I have a form that contains a link button. When the user clicks the link
button I need to enable a couple of other buttons on the page and open a new
browser window giving it focus (keeping it on top). I have most of it working
but I can't get it all working. I can either have the window open and disable
the buttons with the new window in the background, or I can have the new
window in the foreground but not be able to disable the buttons. Here's why:

In the pageLoad of the main form, I add an onclick attribute to the link
button that creates the new browser window using window.open:

lbLinkButton.Attributes.Add("onclick", "var w=window.open('" &
"newPage.aspx" & "'); w.focus();")

When the user clicks on the link button, the window.open gets fired and then
the link button's click event fires and I enable the other buttons on my
page. The problem is that the new window appears on top for a brief period
then disappears to the background (I assume when the rest of the code behind
for the main form executes).

I was able to get the new browser window to stay in the foreground by adding
"return false" to the above attribute as in:

lbLinkButton.Attributes.Add("onclick", "var w=window.open('" &
"newPage.aspx" & "'); w.focus(); return false;")

The problem I now have with the return false is that execution doesn't
return to the main form's code behind; the link button's click event never
gets trapped.

Does anyone know of a solution to this problem?
Thanks,

Carlo.
Nov 19 '05 #1
2 2804
carlor wrote:
Hi there,

I have a form that contains a link button. When the user clicks the link
button I need to enable a couple of other buttons on the page and open a new
browser window giving it focus (keeping it on top). I have most of it working
but I can't get it all working. I can either have the window open and disable
the buttons with the new window in the background, or I can have the new
window in the foreground but not be able to disable the buttons. Here's why:

In the pageLoad of the main form, I add an onclick attribute to the link
button that creates the new browser window using window.open:

lbLinkButton.Attributes.Add("onclick", "var w=window.open('" &
"newPage.aspx" & "'); w.focus();")

When the user clicks on the link button, the window.open gets fired and then
the link button's click event fires and I enable the other buttons on my
page. The problem is that the new window appears on top for a brief period
then disappears to the background (I assume when the rest of the code behind
for the main form executes).

I was able to get the new browser window to stay in the foreground by adding
"return false" to the above attribute as in:

lbLinkButton.Attributes.Add("onclick", "var w=window.open('" &
"newPage.aspx" & "'); w.focus(); return false;")

The problem I now have with the return false is that execution doesn't
return to the main form's code behind; the link button's click event never
gets trapped.

Does anyone know of a solution to this problem?

Could you not, instead of hooking into the onclick event, have the
following within the button click event:

Response.RegisterClientScriptBlock("PopNewWindow", "<script
type=""text/javascript"">var w=window.open('newPage.aspx');
w.focus();</script>")

Which would then open the window after the postback has completed...

Nov 19 '05 #2
Hi Damien,

Thanks for the reply but unfortunately it didn't work. The page did not
open. BTW, I had to change from "Response" to "Page".

Thanks,

Carlo.

"Damien" wrote:
Could you not, instead of hooking into the onclick event, have the
following within the button click event:

Response.RegisterClientScriptBlock("PopNewWindow", "<script
type=""text/javascript"">var w=window.open('newPage.aspx');
w.focus();</script>")

Which would then open the window after the postback has completed...


Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by lukeo | last post: by
6 posts views Thread by Les | last post: by
2 posts views Thread by venkatesh | last post: by
10 posts views Thread by David McCulloch | last post: by
2 posts views Thread by Samir Pandey | last post: by
8 posts views Thread by Dominic Tocci | last post: by
13 posts views Thread by Seth Grimes | last post: by
16 posts views Thread by CreativeMind | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.