473,406 Members | 2,894 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 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 2917
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Paul | last post by:
I link to a web site from an Excel spreadsheet. The page i link to is getCookie.asp which sets a cookie then returns back some html which opens a new window, to the same site but a different page...
6
by: lukeo | last post by:
I'm shelling out to an .asp (or htm) page from an application. I want to show this in a window without the address bar, etc... Is there a way I can redirect this page using javascript to a page...
6
by: Les | last post by:
Hi, I'd like to find out how to use the window.open() script in Fireworks MX. I have posted my question in the Fireworks forum but didn't get any replies. Since it's javascript, maybe someone...
2
by: venkatesh | last post by:
Hi Members, I have used the below mentioned code to open a html page in a new browser. The window size is 200 x 300. In that browser, I've given code to open another browser of the same size....
10
by: David McCulloch | last post by:
The following code opens a new window, but the "resizeTo" doesn't resize it. Why not? (Don't ask why I simply did not open the window with the new size....my original problem was how to open a...
2
by: Samir Pandey | last post by:
Hello, I am using the following javascript code to open a new window. Somehow, IE always opens a new window. It doesn't open target url in the window name given. All i want is, if there is a...
8
by: Dominic Tocci | last post by:
I'm searching for a way to use window.open on my web page to open a window in firefox that allows the sidebars to work (bookmarks, history, etc). When I use the following: var...
13
by: Seth Grimes | last post by:
Hello all, I want to open a window when a user leaves my site. I set up a function called by onUnload. To skip the window.open if the user hasn't left my site, I set a variable in my links and...
16
by: CreativeMind | last post by:
hi, i have a page calendar.aspx which returns selected date i.e window.returnValue=selectedDate; window.close(); it works fine with IE but not for Firefox. i tried...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.