472,139 Members | 1,359 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

window.open

hey guys i've got a question as to why something is happening.

basically building a web application, and i want to open up another .aspx form, but not
close the one i have.

so, i assign a button this.

MyButton.Attributes.Add("onclick", "window.open('MyForm.aspx');")

it works great but, it takes two clicks before it responds. i really do like the effect of the other .aspx file opening, leaving the main.aspx intact.
i was just wondering why, it takes "two-clicks".

the other thing i like is, it's minimal code.

does anyone know, why and is there a better solution, than the one i'm using?

thanks again

rik
************************************************** ********************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
Nov 19 '05 #1
4 2752
rik butcher wrote:
hey guys i've got a question as to why something is happening.

basically building a web application, and i want to open up another
.aspx form, but not
close the one i have.

so, i assign a button this.

MyButton.Attributes.Add("onclick", "window.open('MyForm.aspx');")

it works great but, it takes two clicks before it responds. i really
do like the effect of the other .aspx file opening, leaving the
main.aspx intact. i was just wondering why, it takes "two-clicks".

the other thing i like is, it's minimal code.

does anyone know, why and is there a better solution, than the one
i'm using?


Where did you put this line of code? Was it in Page_Load, or was it in an
event handler?
It should be in Page_Load.

--

Riki
Nov 19 '05 #2
it's basically in a click_event:

Private Sub btnHelp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHelp.Click
btnHelp.Attributes.Add("onclick", "window.open('Help.aspx');")
End Sub

i guess i'm a little confused on why this would be in page load, since it's based on a click event. but, i'm pretty new to web apps.

do you mean build a Load template like this?:

Private Sub btnHelp_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnHelp.Load
btnHelp.Attributes.Add("onclick", "window.open('Help.aspx');")
End Sub
i changed to this and it's a one click now.

thanks
rik

************************************************** ********************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
Nov 19 '05 #3
rik butcher wrote:
i guess i'm a little confused on why this would be in page load,
since it's based on a click event. but, i'm pretty new to web apps.


The reason is that the client script is only added after
the first Click event is handled on the server.

This means:
1) you click
2) server adds client script
3) you have to click again to activate the client script.

Hope this makes it clear for you.

--

Riki
Nov 19 '05 #4
Alternativley you could just put

onclick="window.open('Help.aspx');"

in the button's tag

ie.

<input type="button" value="Click This Button for Help"
onclick="window.open('Help.aspx');" />

--
Martin Eyles
ma**********@NOSPAM.bytronic.com

"Riki" <ri**@nospam.com> wrote in message
news:eg**************@TK2MSFTNGP15.phx.gbl...
rik butcher wrote:
i guess i'm a little confused on why this would be in page load,
since it's based on a click event. but, i'm pretty new to web apps.


The reason is that the client script is only added after
the first Click event is handled on the server.

This means:
1) you click
2) server adds client script
3) you have to click again to activate the client script.

Hope this makes it clear for you.

--

Riki

Nov 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Michael | last post: by
13 posts views Thread by Kai Grossjohann | last post: by
10 posts views Thread by Marshall Dudley | last post: by
2 posts views Thread by Samir Pandey | last post: by
3 posts views Thread by NeverLift | last post: by
14 posts views Thread by D. Alvarado | last post: by
6 posts views Thread by G Dean Blake | last post: by
7 posts views Thread by anthony.turcotte | last post: by
3 posts views Thread by Andrew Poulos | last post: by
reply views Thread by leo001 | 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.