473,223 Members | 1,802 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,223 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 2911
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: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.