Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Close window on condition


Message #1 by williams@s... on Fri, 14 Sep 2001 10:15:25 -0400

Hi,





I have ASP1 which opens a new window ASP2 using VBScript window.open



originally, after processing in ASP2, user is asked to click on button to

close window which returns 2 values to ASP1:



<script language=vbscript>

Sub cmd_onClick()



opener.document.all("Field1").value=intVar1

opener.document.all("Field2").value=intVar2

window.close



End Sub

</script>





However, user now want to have ASP2 close auto after processing under Case1

condition and click on the button to close window on Case2 condition. On

both conditions, I need to return the 2 values to Field1 & Field2 in ASP1.



Would anyone can help me on that.





Thanks in advance

William



Message #2 by "Daniel O'Dorisio" <dodorisio@h...> on Fri, 14 Sep 2001 11:00:04 -0400
Yeah. In your case statements. Write out the clientside vbscript. But

don't put it in a sub or function. Just write it out. And it will

execute. On case 2 write out the button and the sub.



P.s. I would use javascript. Vbscript is not compatible with ns



daniel



-----Original Message-----

From: williams@s... [mailto:williams@s...] 

Sent: Friday, September 14, 2001 10:15 AM

To: ASP Web HowTo

Subject: [asp_web_howto] Close window on condition







Hi,





I have ASP1 which opens a new window ASP2 using VBScript window.open



originally, after processing in ASP2, user is asked to click on button

to close window which returns 2 values to ASP1:



<script language=vbscript>

Sub cmd_onClick()



opener.document.all("Field1").value=intVar1

opener.document.all("Field2").value=intVar2

window.close



End Sub

</script>





However, user now want to have ASP2 close auto after processing under

Case1 condition and click on the button to close window on Case2

condition. On both conditions, I need to return the 2 values to Field1 &

Field2 in ASP1.



Would anyone can help me on that.





Thanks in advance

William



Message #3 by williams@s... on Fri, 14 Sep 2001 11:56:45 -0400
Daniel,



I have both intVar1 & intVar2 both calc. in ASP and store in hidden field

and grap the values in Sub. Without the sub it gives the object required

message.



Do you mind give me the code.



Thanks

William







                                                                                                                   

                    "Daniel                                                                                        

                    O'Dorisio"           To:     "ASP Web HowTo" <asp_web_howto@p...>                      

                    <dodorisio@h...       cc:                                                                       

                    e.com>               Subject:     [asp_web_howto] RE: Close window on condition                

                                                                                                                   

                    09/14/2001                                                                                     

                    11:00 AM                                                                                       

                    Please respond                                                                                 

                    to "ASP Web                                                                                    

                    HowTo"                                                                                         

                                                                                                                   

                                                                                                                   









Yeah. In your case statements. Write out the clientside vbscript. But

don't put it in a sub or function. Just write it out. And it will

execute. On case 2 write out the button and the sub.



P.s. I would use javascript. Vbscript is not compatible with ns



daniel



-----Original Message-----

From: williams@s... [mailto:williams@s...]

Sent: Friday, September 14, 2001 10:15 AM

To: ASP Web HowTo

Subject: [asp_web_howto] Close window on condition







Hi,





I have ASP1 which opens a new window ASP2 using VBScript window.open



originally, after processing in ASP2, user is asked to click on button

to close window which returns 2 values to ASP1:



<script language=vbscript>

Sub cmd_onClick()



opener.document.all("Field1").value=intVar1

opener.document.all("Field2").value=intVar2

window.close



End Sub

</script>





However, user now want to have ASP2 close auto after processing under

Case1 condition and click on the button to close window on Case2

condition. On both conditions, I need to return the 2 values to Field1 &

Field2 in ASP1.



Would anyone can help me on that.





Thanks in advance

William
Message #4 by williams@s... on Fri, 14 Sep 2001 14:58:41 -0400
Daniel,



I tried the following for case1 to close window without click close button,

but it gave me IE error: object required: 'document.all[...]'



<%

intCount = intCount+1

Response.Write " <input type=hidden name=FieldA value=" & intCount & ">"

Response.Write (vbCrLf & "<script language=vbscript>" & vbCrLf )

Response.Write ("Dim intVar1" & vbCrLf)

Response.Write ("intVar1 = document.all(" & chr(34) & "FieldA" & chr(34) &

").value" & vbCrLf )

Response.Write ("opener.document.all(" & & chr(34) & "Field1" & chr(34) &

").value=" & chr(34) & intVar1 & chr(34) & vbCrLf )

Response.Write ("opener.document.all(" & & chr(34) & "Field2" & chr(34) &

").value=" & chr(34) & "" & chr(34) & vbCrLf )

Response.Write ("window.close" & vbCrLf)

Response.Write("</script>" & vbCrLf)

%>



Please help.



Thanks

William





                                                                                                                   

                    William Sze                                                                                    

                                         To:     "ASP Web HowTo" <asp_web_howto@p...>                      

                    09/14/2001           cc:                                                                       

                    11:56 AM             Subject:     Re: [asp_web_howto] RE: Close window on condition(Document   

                                         link: William Sze)                                                        

                                                                                                                   







Daniel,



I have both intVar1 & intVar2 both calc. in ASP and store in hidden field

and grap the values in Sub. Without the sub it gives the object required

message.



Do you mind give me the code.



Thanks

William







                                                                                                                   

                    "Daniel                                                                                        

                    O'Dorisio"           To:     "ASP Web HowTo" <asp_web_howto@p...>                      

                    <dodorisio@h...       cc:                                                                       

                    e.com>               Subject:     [asp_web_howto] RE: Close window on condition                

                                                                                                                   

                    09/14/2001                                                                                     

                    11:00 AM                                                                                       

                    Please respond                                                                                 

                    to "ASP Web                                                                                    

                    HowTo"                                                                                         

                                                                                                                   

                                                                                                                   









Yeah. In your case statements. Write out the clientside vbscript. But

don't put it in a sub or function. Just write it out. And it will

execute. On case 2 write out the button and the sub.



P.s. I would use javascript. Vbscript is not compatible with ns



daniel



-----Original Message-----

From: williams@s... [mailto:williams@s...]

Sent: Friday, September 14, 2001 10:15 AM

To: ASP Web HowTo

Subject: [asp_web_howto] Close window on condition







Hi,





I have ASP1 which opens a new window ASP2 using VBScript window.open



originally, after processing in ASP2, user is asked to click on button

to close window which returns 2 values to ASP1:



<script language=vbscript>

Sub cmd_onClick()



opener.document.all("Field1").value=intVar1

opener.document.all("Field2").value=intVar2

window.close



End Sub

</script>





However, user now want to have ASP2 close auto after processing under

Case1 condition and click on the button to close window on Case2

condition. On both conditions, I need to return the 2 values to Field1 &

Field2 in ASP1.



Would anyone can help me on that.





Thanks in advance

William

Message #5 by "Daniel O'Dorisio" <dodorisio@h...> on Fri, 14 Sep 2001 15:14:08 -0400
Is that element created on the page yet? Maybe you didn't add it to the

page. (this happens to me when I copy and paste code sometimes)



I have done this in javascript. But never messed arround with clientside

vbscript. 



I guess the only thing I can say is just look over your code for

spelling errors, and make sure the object is there:-)



daniel



-----Original Message-----

From: williams@s... [mailto:williams@s...] 

Sent: Friday, September 14, 2001 2:59 PM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Close window on condition





Daniel,



I tried the following for case1 to close window without click close

button, but it gave me IE error: object required: 'document.all[...]'



<%

intCount = intCount+1

Response.Write " <input type=hidden name=FieldA value=" & intCount & ">"

Response.Write (vbCrLf & "<script language=vbscript>" & vbCrLf )

Response.Write ("Dim intVar1" & vbCrLf) Response.Write ("intVar1 

document.all(" & chr(34) & "FieldA" & chr(34) & ").value" & vbCrLf )

Response.Write ("opener.document.all(" & & chr(34) & "Field1" & chr(34)

& ").value=" & chr(34) & intVar1 & chr(34) & vbCrLf ) Response.Write

("opener.document.all(" & & chr(34) & "Field2" & chr(34) & ").value=" &

chr(34) & "" & chr(34) & vbCrLf ) Response.Write ("window.close" &

vbCrLf) Response.Write("</script>" & vbCrLf) %>



Please help.



Thanks

William

Message #6 by "Alex Shiell, ITS, EC, SE" <alex.shiell@s...> on Mon, 17 Sep 2001 10:24:41 +0100
I'm going to put in my quidsworth here...



There's a lot of ASP "purists" out there that will tell you that context

switching is "bad" and you mustn't use it at all, and that you should

response.write every line of your page.  It is true that context switching

does impact on performance, but the reality is that the impact is small.  As

long as you structure your ASP in such a way that context switching is kept

to a minimum, you will not notice any difference in performance.  For any

large blocks of HTML or client side scripting you really should switch the

context as it will make errors like this far easier to debug.



looking at this code, its just a mess:



Response.Write (vbCrLf & "<script language=vbscript>" & vbCrLf )

Response.Write ("Dim intVar1" & vbCrLf)

Response.Write ("intVar1 = document.all(" & chr(34) & "FieldA" & chr(34) &

").value" & vbCrLf )

Response.Write ("opener.document.all(" & & chr(34) & "Field1" & chr(34) &

").value=" & chr(34) & intVar1 & chr(34) & vbCrLf )

Response.Write ("opener.document.all(" & & chr(34) & "Field2" & chr(34) &

").value=" & chr(34) & "" & chr(34) & vbCrLf )

Response.Write ("window.close" & vbCrLf)

Response.Write("</script>" & vbCrLf)



write it like this, and its so much clearer.



%>

<script language=vbscript>

Dim intVar1

intVar1 = document.all("FieldA").value

opener.document.all("Field1").value=intVar1

opener.document.all("Field2").value=""

window.close

</script>

<%



And I promise you, you will not notice any difference in performance.  If

you've got a lot of client side code, you should really stick it into a

seperate .js (or .vbs) file anyway.



In any case, to get back to your actual problem.  As you are using

client-side vbscript, you are obviously only supporting MSIE, in which case

you can reference elements on your page directly.  e.g. you can just say 



<script language=vbscript>

Dim intVar1

intVar1 = FieldA.value

opener.document.Field1.value=intVar1

opener.document.Field2.value=""

window.close

</script>



(unless your elements are in a form, in which case you need to include the

form name)



If you were using javascript and wanted to support netscape 6 as well, then

the correct syntax would be



intVar1 = document.getElementById("FieldA").value





-----Original Message-----

From: williams@s... [mailto:williams@s...]

Sent: 14 September 2001 19:59

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Close window on condition





Daniel,



I tried the following for case1 to close window without click close button,

but it gave me IE error: object required: 'document.all[...]'



<%

intCount = intCount+1

Response.Write " <input type=hidden name=FieldA value=" & intCount & ">"

Response.Write (vbCrLf & "<script language=vbscript>" & vbCrLf )

Response.Write ("Dim intVar1" & vbCrLf)

Response.Write ("intVar1 = document.all(" & chr(34) & "FieldA" & chr(34) &

").value" & vbCrLf )

Response.Write ("opener.document.all(" & & chr(34) & "Field1" & chr(34) &

").value=" & chr(34) & intVar1 & chr(34) & vbCrLf )

Response.Write ("opener.document.all(" & & chr(34) & "Field2" & chr(34) &

").value=" & chr(34) & "" & chr(34) & vbCrLf )

Response.Write ("window.close" & vbCrLf)

Response.Write("</script>" & vbCrLf)

%>



Please help.



Thanks

William





 



                    William Sze



                                         To:     "ASP Web HowTo"

<asp_web_howto@p...>                      

                    09/14/2001           cc:



                    11:56 AM             Subject:     Re: [asp_web_howto]

RE: Close window on condition(Document   

                                         link: William Sze)



 









Daniel,



I have both intVar1 & intVar2 both calc. in ASP and store in hidden field

and grap the values in Sub. Without the sub it gives the object required

message.



Do you mind give me the code.



Thanks

William







 



                    "Daniel



                    O'Dorisio"           To:     "ASP Web HowTo"

<asp_web_howto@p...>                      

                    <dodorisio@h...       cc:



                    e.com>               Subject:     [asp_web_howto] RE:

Close window on condition                

 



                    09/14/2001



                    11:00 AM



                    Please respond



                    to "ASP Web



                    HowTo"



 



 











Yeah. In your case statements. Write out the clientside vbscript. But

don't put it in a sub or function. Just write it out. And it will

execute. On case 2 write out the button and the sub.



P.s. I would use javascript. Vbscript is not compatible with ns



daniel



-----Original Message-----

From: williams@s... [mailto:williams@s...]

Sent: Friday, September 14, 2001 10:15 AM

To: ASP Web HowTo

Subject: [asp_web_howto] Close window on condition







Hi,





I have ASP1 which opens a new window ASP2 using VBScript window.open



originally, after processing in ASP2, user is asked to click on button

to close window which returns 2 values to ASP1:



<script language=vbscript>

Sub cmd_onClick()



opener.document.all("Field1").value=intVar1

opener.document.all("Field2").value=intVar2

window.close



End Sub

</script>





However, user now want to have ASP2 close auto after processing under

Case1 condition and click on the button to close window on Case2

condition. On both conditions, I need to return the 2 values to Field1 &

Field2 in ASP1.



Would anyone can help me on that.





Thanks in advance

William
Message #7 by "Daniel O'Dorisio" <dodorisio@h...> on Mon, 17 Sep 2001 10:30:57 -0400
I agree.. I usually switch context if it is a large block of script. And

then usually I create all my script as functions in the head of the

page. And then call the function from within asp:



My pages generally look like:



<%@LANGUAGE=Vbscript%>

<%option explicit%>

<!--#INCLUDE FILE="site.asp"-->

<html>

<head>

<title>Page.asp</title>

<script language=javascript>

	function bla(bla){

	...

	}

</script>

</head>

<body>

<% 

Select case request.querystring("name")

	case "daniel"

		With response

		  .Write "<script language=javascript>" &vbcrlf

		  .Write "bla(daniel); &vbcrlf"

		  .write "</script>"

		end with

	Case else

		'problem

End select

%>

</body>

</html>



I dunno if that is any better or not. That is just how I like to do it.



daniel





-----Original Message-----

From: Alex Shiell, ITS, EC, SE [mailto:alex.shiell@s...] 

Sent: Monday, September 17, 2001 5:25 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Close window on condition





I'm going to put in my quidsworth here...



There's a lot of ASP "purists" out there that will tell you that context

switching is "bad" and you mustn't use it at all, and that you should

response.write every line of your page.  It is true that context

switching does impact on performance, but the reality is that the impact

is small.  As long as you structure your ASP in such a way that context

switching is kept to a minimum, you will not notice any difference in

performance.  For any large blocks of HTML or client side scripting you

really should switch the context as it will make errors like this far

easier to debug.



looking at this code, its just a mess:



Response.Write (vbCrLf & "<script language=vbscript>" & vbCrLf )

Response.Write ("Dim intVar1" & vbCrLf) Response.Write ("intVar1 

document.all(" & chr(34) & "FieldA" & chr(34) & ").value" & vbCrLf )

Response.Write ("opener.document.all(" & & chr(34) & "Field1" & chr(34)

& ").value=" & chr(34) & intVar1 & chr(34) & vbCrLf ) Response.Write

("opener.document.all(" & & chr(34) & "Field2" & chr(34) & ").value=" &

chr(34) & "" & chr(34) & vbCrLf ) Response.Write ("window.close" &

vbCrLf) Response.Write("</script>" & vbCrLf)



write it like this, and its so much clearer.



%>

<script language=vbscript>

Dim intVar1

intVar1 = document.all("FieldA").value

opener.document.all("Field1").value=intVar1

opener.document.all("Field2").value=""

window.close

</script>

<%



And I promise you, you will not notice any difference in performance.

If you've got a lot of client side code, you should really stick it into

a seperate .js (or .vbs) file anyway.



In any case, to get back to your actual problem.  As you are using

client-side vbscript, you are obviously only supporting MSIE, in which

case you can reference elements on your page directly.  e.g. you can

just say 



<script language=vbscript>

Dim intVar1

intVar1 = FieldA.value

opener.document.Field1.value=intVar1

opener.document.Field2.value=""

window.close

</script>



(unless your elements are in a form, in which case you need to include

the form name)



If you were using javascript and wanted to support netscape 6 as well,

then the correct syntax would be



intVar1 = document.getElementById("FieldA").value





-----Original Message-----

From: williams@s... [mailto:williams@s...]

Sent: 14 September 2001 19:59

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Close window on condition





Daniel,



I tried the following for case1 to close window without click close

button, but it gave me IE error: object required: 'document.all[...]'



<%

intCount = intCount+1

Response.Write " <input type=hidden name=FieldA value=" & intCount & ">"

Response.Write (vbCrLf & "<script language=vbscript>" & vbCrLf )

Response.Write ("Dim intVar1" & vbCrLf) Response.Write ("intVar1 

document.all(" & chr(34) & "FieldA" & chr(34) & ").value" & vbCrLf )

Response.Write ("opener.document.all(" & & chr(34) & "Field1" & chr(34)

& ").value=" & chr(34) & intVar1 & chr(34) & vbCrLf ) Response.Write

("opener.document.all(" & & chr(34) & "Field2" & chr(34) & ").value=" &

chr(34) & "" & chr(34) & vbCrLf ) Response.Write ("window.close" &

vbCrLf) Response.Write("</script>" & vbCrLf) %>



Please help.



Thanks

William





 



                    William Sze



                                         To:     "ASP Web HowTo"

<asp_web_howto@p...>                      

                    09/14/2001           cc:



                    11:56 AM             Subject:     Re:

[asp_web_howto]

RE: Close window on condition(Document   

                                         link: William Sze)



 









Daniel,



I have both intVar1 & intVar2 both calc. in ASP and store in hidden

field and grap the values in Sub. Without the sub it gives the object

required message.



Do you mind give me the code.



Thanks

William







 



                    "Daniel



                    O'Dorisio"           To:     "ASP Web HowTo"

<asp_web_howto@p...>                      

                    <dodorisio@h...       cc:



                    e.com>               Subject:     [asp_web_howto]

RE:

Close window on condition                

 



                    09/14/2001



                    11:00 AM



                    Please respond



                    to "ASP Web



                    HowTo"



 



 











Yeah. In your case statements. Write out the clientside vbscript. But

don't put it in a sub or function. Just write it out. And it will

execute. On case 2 write out the button and the sub.



P.s. I would use javascript. Vbscript is not compatible with ns



daniel



-----Original Message-----

From: williams@s... [mailto:williams@s...]

Sent: Friday, September 14, 2001 10:15 AM

To: ASP Web HowTo

Subject: [asp_web_howto] Close window on condition







Hi,





I have ASP1 which opens a new window ASP2 using VBScript window.open



originally, after processing in ASP2, user is asked to click on button

to close window which returns 2 values to ASP1:



<script language=vbscript>

Sub cmd_onClick()



opener.document.all("Field1").value=intVar1

opener.document.all("Field2").value=intVar2

window.close



End Sub

</script>





However, user now want to have ASP2 close auto after processing under

Case1 condition and click on the button to close window on Case2

condition. On both conditions, I need to return the 2 values to Field1 &

Field2 in ASP1.



Would anyone can help me on that.





Thanks in advance

William
Message #8 by "Alex Shiell, ITS, EC, SE" <alex.shiell@s...> on Mon, 17 Sep 2001 16:46:41 +0100
Yes, this is a very good approach.  The page is laid out in such a way that

context switching is kept to a minimum, and the different parts remain

clearly identifiable.  Move your javascript functions into js files and it

would be even better!



-----Original Message-----

From: Daniel O'Dorisio [mailto:dodorisio@h...]

Sent: 17 September 2001 15:31

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Close window on condition





I agree.. I usually switch context if it is a large block of script. And

then usually I create all my script as functions in the head of the

page. And then call the function from within asp:



My pages generally look like:



<%@LANGUAGE=Vbscript%>

<%option explicit%>

<!--#INCLUDE FILE="site.asp"-->

<html>

<head>

<title>Page.asp</title>

<script language=javascript>

	function bla(bla){

	...

	}

</script>

</head>

<body>

<% 

Select case request.querystring("name")

	case "daniel"

		With response

		  .Write "<script language=javascript>" &vbcrlf

		  .Write "bla(daniel); &vbcrlf"

		  .write "</script>"

		end with

	Case else

		'problem

End select

%>

</body>

</html>



I dunno if that is any better or not. That is just how I like to do it.



daniel





-----Original Message-----

From: Alex Shiell, ITS, EC, SE [mailto:alex.shiell@s...] 

Sent: Monday, September 17, 2001 5:25 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Close window on condition





I'm going to put in my quidsworth here...



There's a lot of ASP "purists" out there that will tell you that context

switching is "bad" and you mustn't use it at all, and that you should

response.write every line of your page.  It is true that context

switching does impact on performance, but the reality is that the impact

is small.  As long as you structure your ASP in such a way that context

switching is kept to a minimum, you will not notice any difference in

performance.  For any large blocks of HTML or client side scripting you

really should switch the context as it will make errors like this far

easier to debug.



looking at this code, its just a mess:



Response.Write (vbCrLf & "<script language=vbscript>" & vbCrLf )

Response.Write ("Dim intVar1" & vbCrLf) Response.Write ("intVar1 

document.all(" & chr(34) & "FieldA" & chr(34) & ").value" & vbCrLf )

Response.Write ("opener.document.all(" & & chr(34) & "Field1" & chr(34)

& ").value=" & chr(34) & intVar1 & chr(34) & vbCrLf ) Response.Write

("opener.document.all(" & & chr(34) & "Field2" & chr(34) & ").value=" &

chr(34) & "" & chr(34) & vbCrLf ) Response.Write ("window.close" &

vbCrLf) Response.Write("</script>" & vbCrLf)



write it like this, and its so much clearer.



%>

<script language=vbscript>

Dim intVar1

intVar1 = document.all("FieldA").value

opener.document.all("Field1").value=intVar1

opener.document.all("Field2").value=""

window.close

</script>

<%



And I promise you, you will not notice any difference in performance.

If you've got a lot of client side code, you should really stick it into

a seperate .js (or .vbs) file anyway.



In any case, to get back to your actual problem.  As you are using

client-side vbscript, you are obviously only supporting MSIE, in which

case you can reference elements on your page directly.  e.g. you can

just say 



<script language=vbscript>

Dim intVar1

intVar1 = FieldA.value

opener.document.Field1.value=intVar1

opener.document.Field2.value=""

window.close

</script>



(unless your elements are in a form, in which case you need to include

the form name)



If you were using javascript and wanted to support netscape 6 as well,

then the correct syntax would be



intVar1 = document.getElementById("FieldA").value





-----Original Message-----

From: williams@s... [mailto:williams@s...]

Sent: 14 September 2001 19:59

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Close window on condition





Daniel,



I tried the following for case1 to close window without click close

button, but it gave me IE error: object required: 'document.all[...]'



<%

intCount = intCount+1

Response.Write " <input type=hidden name=FieldA value=" & intCount & ">"

Response.Write (vbCrLf & "<script language=vbscript>" & vbCrLf )

Response.Write ("Dim intVar1" & vbCrLf) Response.Write ("intVar1 

document.all(" & chr(34) & "FieldA" & chr(34) & ").value" & vbCrLf )

Response.Write ("opener.document.all(" & & chr(34) & "Field1" & chr(34)

& ").value=" & chr(34) & intVar1 & chr(34) & vbCrLf ) Response.Write

("opener.document.all(" & & chr(34) & "Field2" & chr(34) & ").value=" &

chr(34) & "" & chr(34) & vbCrLf ) Response.Write ("window.close" &

vbCrLf) Response.Write("</script>" & vbCrLf) %>



Please help.



Thanks

William





 



                    William Sze



                                         To:     "ASP Web HowTo"

<asp_web_howto@p...>                      

                    09/14/2001           cc:



                    11:56 AM             Subject:     Re:

[asp_web_howto]

RE: Close window on condition(Document   

                                         link: William Sze)



 









Daniel,



I have both intVar1 & intVar2 both calc. in ASP and store in hidden

field and grap the values in Sub. Without the sub it gives the object

required message.



Do you mind give me the code.



Thanks

William
Message #9 by "Daniel O'Dorisio" <dodorisio@h...> on Mon, 17 Sep 2001 11:45:01 -0400
Good idea.. But I don't use much js. I will keep that in mind though!



-----Original Message-----

From: Alex Shiell, ITS, EC, SE [mailto:alex.shiell@s...] 

Sent: Monday, September 17, 2001 11:47 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Close window on condition





Yes, this is a very good approach.  The page is laid out in such a way

that context switching is kept to a minimum, and the different parts

remain clearly identifiable.  Move your javascript functions into js

files and it would be even better!



-----Original Message-----

From: Daniel O'Dorisio [mailto:dodorisio@h...]

Sent: 17 September 2001 15:31

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Close window on condition





I agree.. I usually switch context if it is a large block of script. And

then usually I create all my script as functions in the head of the

page. And then call the function from within asp:



My pages generally look like:



<%@LANGUAGE=Vbscript%>

<%option explicit%>

<!--#INCLUDE FILE="site.asp"-->

<html>

<head>

<title>Page.asp</title>

<script language=javascript>

	function bla(bla){

	...

	}

</script>

</head>

<body>

<% 

Select case request.querystring("name")

	case "daniel"

		With response

		  .Write "<script language=javascript>" &vbcrlf

		  .Write "bla(daniel); &vbcrlf"

		  .write "</script>"

		end with

	Case else

		'problem

End select

%>

</body>

</html>



I dunno if that is any better or not. That is just how I like to do it.



daniel





-----Original Message-----

From: Alex Shiell, ITS, EC, SE [mailto:alex.shiell@s...] 

Sent: Monday, September 17, 2001 5:25 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Close window on condition





I'm going to put in my quidsworth here...



There's a lot of ASP "purists" out there that will tell you that context

switching is "bad" and you mustn't use it at all, and that you should

response.write every line of your page.  It is true that context

switching does impact on performance, but the reality is that the impact

is small.  As long as you structure your ASP in such a way that context

switching is kept to a minimum, you will not notice any difference in

performance.  For any large blocks of HTML or client side scripting you

really should switch the context as it will make errors like this far

easier to debug.



looking at this code, its just a mess:



Response.Write (vbCrLf & "<script language=vbscript>" & vbCrLf )

Response.Write ("Dim intVar1" & vbCrLf) Response.Write ("intVar1 

document.all(" & chr(34) & "FieldA" & chr(34) & ").value" & vbCrLf )

Response.Write ("opener.document.all(" & & chr(34) & "Field1" & chr(34)

& ").value=" & chr(34) & intVar1 & chr(34) & vbCrLf ) Response.Write

("opener.document.all(" & & chr(34) & "Field2" & chr(34) & ").value=" &

chr(34) & "" & chr(34) & vbCrLf ) Response.Write ("window.close" &

vbCrLf) Response.Write("</script>" & vbCrLf)



write it like this, and its so much clearer.



%>

<script language=vbscript>

Dim intVar1

intVar1 = document.all("FieldA").value

opener.document.all("Field1").value=intVar1

opener.document.all("Field2").value=""

window.close

</script>

<%



And I promise you, you will not notice any difference in performance. If

you've got a lot of client side code, you should really stick it into a

seperate .js (or .vbs) file anyway.



In any case, to get back to your actual problem.  As you are using

client-side vbscript, you are obviously only supporting MSIE, in which

case you can reference elements on your page directly.  e.g. you can

just say 



<script language=vbscript>

Dim intVar1

intVar1 = FieldA.value

opener.document.Field1.value=intVar1

opener.document.Field2.value=""

window.close

</script>



(unless your elements are in a form, in which case you need to include

the form name)



If you were using javascript and wanted to support netscape 6 as well,

then the correct syntax would be



intVar1 = document.getElementById("FieldA").value





-----Original Message-----

From: williams@s... [mailto:williams@s...]

Sent: 14 September 2001 19:59

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Close window on condition





Daniel,



I tried the following for case1 to close window without click close

button, but it gave me IE error: object required: 'document.all[...]'



<%

intCount = intCount+1

Response.Write " <input type=hidden name=FieldA value=" & intCount & ">"

Response.Write (vbCrLf & "<script language=vbscript>" & vbCrLf )

Response.Write ("Dim intVar1" & vbCrLf) Response.Write ("intVar1 

document.all(" & chr(34) & "FieldA" & chr(34) & ").value" & vbCrLf )

Response.Write ("opener.document.all(" & & chr(34) & "Field1" & chr(34)

& ").value=" & chr(34) & intVar1 & chr(34) & vbCrLf ) Response.Write

("opener.document.all(" & & chr(34) & "Field2" & chr(34) & ").value=" &

chr(34) & "" & chr(34) & vbCrLf ) Response.Write ("window.close" &

vbCrLf) Response.Write("</script>" & vbCrLf) %>



Please help.



Thanks

William





 



                    William Sze



                                         To:     "ASP Web HowTo"

<asp_web_howto@p...>                      

                    09/14/2001           cc:



                    11:56 AM             Subject:     Re:

[asp_web_howto]

RE: Close window on condition(Document   

                                         link: William Sze)



 









Daniel,



I have both intVar1 & intVar2 both calc. in ASP and store in hidden

field and grap the values in Sub. Without the sub it gives the object

required message.



Do you mind give me the code.



Thanks

William
Message #10 by williams@s... on Mon, 17 Sep 2001 13:22:01 -0400
Thanks a lot Alex and Daniel.

From both of your advise. I got it work to close window auto under case 1

and request user to click close window button on case 2 and successfully

return the values to ASP1 from ASP2.



William





                                                                                                                   

                    "Daniel                                                                                        

                    O'Dorisio"           To:     "ASP Web HowTo" <asp_web_howto@p...>                      

                    <dodorisio@h...       cc:                                                                       

                    e.com>               Subject:     [asp_web_howto] RE: Close window on condition                

                                                                                                                   

                    09/17/2001                                                                                     

                    11:45 AM                                                                                       

                    Please respond                                                                                 

                    to "ASP Web                                                                                    

                    HowTo"                                                                                         

                                                                                                                   

                                                                                                                   









Good idea.. But I don't use much js. I will keep that in mind though!



-----Original Message-----

From: Alex Shiell, ITS, EC, SE [mailto:alex.shiell@s...]

Sent: Monday, September 17, 2001 11:47 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Close window on condition





Yes, this is a very good approach.  The page is laid out in such a way

that context switching is kept to a minimum, and the different parts

remain clearly identifiable.  Move your javascript functions into js

files and it would be even better!



-----Original Message-----

From: Daniel O'Dorisio [mailto:dodorisio@h...]

Sent: 17 September 2001 15:31

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Close window on condition





I agree.. I usually switch context if it is a large block of script. And

then usually I create all my script as functions in the head of the

page. And then call the function from within asp:



My pages generally look like:



<%@LANGUAGE=Vbscript%>

<%option explicit%>

<!--#INCLUDE FILE="site.asp"-->

<html>

<head>

<title>Page.asp</title>

<script language=javascript>

           function bla(bla){

           ...

           }

</script>

</head>

<body>

<%

Select case request.querystring("name")

           case "daniel"

                     With response

                       .Write "<script language=javascript>" &vbcrlf

                       .Write "bla(daniel); &vbcrlf"

                       .write "</script>"

                     end with

           Case else

                     'problem

End select

%>

</body>

</html>



I dunno if that is any better or not. That is just how I like to do it.



daniel


  Return to Index