Opening Multiple Windows

  • Thread starter Thread starter Evan Kontos
  • Start date Start date
E

Evan Kontos

I am using the window.open function to open a small window and I am
using GET to get values back from that window. I want to be able to open
another from the second window but I get an error message when I try to
do another window.open. Any suggestions are welcomed.

Evan Kontos | (e-mail address removed)

27 Whitehall St. | 3rd Floor | New York, NY 10004
Tel 212.480.8166 | Fax 212.480.8167 | Personal Fax 786.513.0295
www.comtekcadd.com
 
Hi Evan,

Did you mean to open a ie window in javascript or vbscript?
If so, how can you use the GET method to get values from an ie window in
client?
Can you post some code? So that I can narrow down the problem more quickly.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
 
Here is the code from the button click from the first form to open the
second form.

Private Sub BTNSlctMvFrm_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles BTNSlctMvFrm.Click

Dim str As String = "<script language
=javascript>{window.open('userselectionform.aspx?formname1=Form1.TBXMvFr
mRm&formname2=Form1.TBXMvFrmFlr&formname3=Form1.TBXMvFrmBldg&formname4=F
orm1.TBXMvFrmSt&formname5=Form1.TBXMvFrmLNm&formname6=Form1.TBXMvFrmFNm'
,"

str += " 'UserSelection','menubar=no,resizable=no,
toolbar=no,scrollbars=no,top=100,left=300,height=400,width=300');}</scri
pt>"

RegisterStartupScript("adf", str)

End Sub


Here is the code from the button click on the second form to close it
and post the info back to fields on the first.

Private Sub BtnCnfmMv_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles BtnCnfmMv.Click

Try
Dim Str As String = "<script language=""javascript"">"

Str = Str & "window.opener." &
HttpContext.Current.Request.QueryString("formname1") & ".value = '" &
DDLRm.SelectedValue & "';"
Str = Str & "window.opener." &
HttpContext.Current.Request.QueryString("formname2") & ".value = '" &
DDLFlr.SelectedValue & "';"
Str = Str & "window.opener." &
HttpContext.Current.Request.QueryString("formname3") & ".value = '" &
DDLBldg.SelectedValue & "';"
Str = Str & "window.opener." &
HttpContext.Current.Request.QueryString("formname4") & ".value = '" &
DDLSite.SelectedValue & "';"
Str = Str & "window.opener." &
HttpContext.Current.Request.QueryString("formname5") & ".value = '" &
Trim(DDLMvNm.SelectedValue.Substring(0,
DDLMvNm.SelectedValue.IndexOf(","))) & "';"
Str = Str & "window.opener." &
HttpContext.Current.Request.QueryString("formname6") & ".value = '" &
Trim(DDLMvNm.SelectedValue.Substring(DDLMvNm.SelectedValue.IndexOf(",")
+ 2)) & "';window.close();"
Str = Str & "</script>"
LiteralRm.Text = Str
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub

I want to be able to open ANOTHER window from the second window, if
nothing more than to place a graphic box on it and show a graphic. Help
please.


Evan Kontos | (e-mail address removed)

27 Whitehall St. | 3rd Floor | New York, NY 10004
Tel 212.480.8166 | Fax 212.480.8167 | Personal Fax 786.513.0295
www.comtekcadd.com
 
Hi Evan,

I can not reproduce the problem. But I have written a demo as below.
[WebForm1.aspx.vb, add a button and textbox onto the WebForm1.aspx]
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim str As String = "<script language
=javascript>{window.opener.Form1.TextBox1.value
='hello';window.close();window.open('http://www.google.com');}</script>"
RegisterStartupScript("a", str)

End Sub


[WebForm2.aspx.vb add a button onto the WebForm2.aspx]
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim str As String = "<script language
=javascript>{window.open('http://localhost/WebApplication4/WebForm2.aspx');}
</script>"
RegisterStartupScript("adf", Str)
End Sub

You may have a test and let me know if it does the job for you.
Did I misunderstand your meaning?
If you have any related question please feel free to let me know.


Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
 
Peter,

Let's make this simple. I want to be able to window.open from one form
to another and then window.open from the second web form to a third. I
want to then be able to close the third form and pass data from the
second form back to the first.


Evan Kontos | (e-mail address removed)

27 Whitehall St. | 3rd Floor | New York, NY 10004
Tel 212.480.8166 | Fax 212.480.8167 | Personal Fax 786.513.0295
www.comtekcadd.com
 
Hi Evan,

Provided there are three forms, A, B and C, each one have textbox and a
button on it.(ButtonA TextBoxA on form A,ButtonB TextBoxB on form B,ButtonC
TextBoxC on form C)

Click ButtonA will open form B, click ButtonB will open formC, input some
text into textBoxC and click the ButtonC will put back the text into
textBoxB and close form C.
click ButtonB will put back the text in TextBoxB into TextBoxA and close
FormB.

or

Provided there are three forms, A, B and C, ButtonA TextBoxA on form
A,ButtonB1 ButtonB2 TextBoxB on form B, TextBoxC on form C)

Click ButtonA will open form B, click ButtonB1 will open formC, input some
text into textBoxC and click the ButtonB2 will put back the text in
TextBoxC into textBoxB and close form C.
click ButtonB will put back the text in TextBoxB into TextBoxA and close
FormB.

Did I misunderstand your meaning?

If you are the latter case, when you use the window.open, the method will
return a reference to the new opened window which can be used to control
the new opened window.

string str = "<script language
=javascript>{window.opener.Form1.TextBox1.value ='hello';var o =
window.open('http://www.google.com');o.close();}</script>";
RegisterStartupScript("a", str);

the o in the code above is the reference to the new opened form. you may
used the reference to close the new opened one.

If you have any related question, please feel free to let me know.



Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
 
Peter,
Using the ABC's of forms, here goes. Form A has a textbox and button
to open form B. Form B has a textbox and button to open form c. Form C
has a graphic box and button to close the form and go back to form B.
Click on the button on form A to open form b. Select some data on form
b. Click on the button to open Form C and display a graphic w/the data
from Form B. Close Form B then close Form B passing the same data back
to the textbox on Form A. Is that clear?


Evan Kontos | (e-mail address removed)

27 Whitehall St. | 3rd Floor | New York, NY 10004
Tel 212.480.8166 | Fax 212.480.8167 | Personal Fax 786.513.0295
www.comtekcadd.com
 
Hi Evan,
from Form B. Close Form B then close Form B passing the same data back
to the textbox on Form A.

From the post, I do not know when you want to close the FormB,Since there
is only one button on the Formb and it is used to open FormC, so I think
perhaps you want to close the Form B and Form C after you have click the
button on FormC.
Anyway, if you want to pass the data to new opened window, you may use the
GET method to pass it in the QueryString HTTP server variable.
Here is my code. I assume that I have a textbox and a button on each Form.

[WebForm1.aspx.vb]
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim str As String = "<script language
=javascript>{window.open('http://localhost/WebApplication4/WebForm2.aspx');}
</script>"
RegisterStartupScript("adf", Str)
End Sub

[WebForm2.aspx.vb]
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim str As String = "<script language
=javascript>{window.open('http://localhost/WebApplication4/WebForm3.aspx?con
tent=" & TextBox1.Text & "');}</script>"
RegisterStartupScript("a", str)
End Sub

[WebForm3.aspx.vb]
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
TextBox1.Text = Request.QueryString("content")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim str As String = "<script language
=javascript>{window.opener.opener.Form1.TextBox1.value ='" & TextBox1.Text
& "';window.close();window.opener.close();}</script>"
RegisterStartupScript("a", str)
End Sub


Did I misunderstand your question? If you have any related quesiton please
feel free to let me know.


Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
 
Back
Top