PDA

View Full Version : asp vs Javascript


alaios
03-22-2003, 09:22 PM
Hi there i has a big problem .. Let me explain it to u
I have a window named A . When i click to a button a new browser opens this will be window B .
The B Window has a login form........
If username,passwod are correct i want to do these 2 things
a)close B window and
b)load an other url in Window A
Where is the problem now....All the pages are written with asp.......
When the user has written correct password and username the response.redirect is being used to transfer him to his page...........
So as u can see icant produce any Javascript to control this 2 windows ....because the respone.redirect sends the user somewhere else before the Javscript code is produced....

What can i do?

raf
03-22-2003, 09:41 PM
why is the logonform in the second window ? can't you just stay in one window ?

I know you can control one window from another one. i've seen a javaapplet that did that (called a "remote control" or something like that. But why make it so complicated?

dominicall
03-22-2003, 10:27 PM
Yep - gotta agree with raf on that one....

Why??? Doesn't need to be anywhere near that complicated - surely???

Mhtml
03-23-2003, 04:30 AM
Why no instead of response.redirect, use response.write?

Eg;
If userLoggedIn <> "no" Then
theUrl = "logsuccess.asp"
Else
theUrl = "logfailure.asp"
End If
response.write("<script>parent.location='"&theUrl&"';window.close;</script>")


Use something like that..

PS: I'm not actually sure about the javascript in that example, I haven't worked with parent windows so it could be wrong. :confused:

alaios
03-23-2003, 08:21 AM
becuase my boss wants to do this....

raf
03-23-2003, 08:50 AM
really ? must be going bad in that firm if your boss has time to occupie himself with that sort a things. Maybe talk to hem (and take dominicall and his golfclubs with you;)

seriously, ask him why he wants that + can't you use the "imput box" function ? A popup appears asking for the user or pasword. You can even include a link to a helpfile and stuff.

Maybe he's thinking about this sort a nice to have features.


more info on popup function from helpfile:
--------------------------------------------------
InputBox Function Language Reference
Version 1


See Also


--------------------------------------------------------------------------------

Description
Displays a prompt in a dialog box, waits for the user to input text or click a button, and returns the contents of the text box.
Syntax
InputBox(prompt[, title][, default][, xpos][, ypos][, helpfile, context])
The InputBox function syntax has these arguments:

Part Description
prompt String expression displayed as the message in the dialog box. The maximum length of prompt is approximately 1024 characters, depending on the width of the characters used. If prompt consists of more than one line, you can separate the lines using a carriage return character (Chr(13)), a linefeed character (Chr(10)), or carriage return–linefeed character combination (Chr(13) & Chr(10)) between each line.
title String expression displayed in the title bar of the dialog box. If you omit title, the application name is placed in the title bar.
default String expression displayed in the text box as the default response if no other input is provided. If you omit default, the text box is displayed empty.
xpos Numeric expression that specifies, in twips, the horizontal distance of the left edge of the dialog box from the left edge of the screen. If xpos is omitted, the dialog box is horizontally centered.
ypos Numeric expression that specifies, in twips, the vertical distance of the upper edge of the dialog box from the top of the screen. If ypos is omitted, the dialog box is vertically positioned approximately one-third of the way down the screen.
helpfile String expression that identifies the Help file to use to provide context-sensitive Help for the dialog box. If helpfile is provided, context must also be provided.
context Numeric expression that identifies the Help context number assigned by the Help author to the appropriate Help topic. If context is provided, helpfile must also be provided.


Remarks
When both helpfile and context are supplied, a Help button is automatically added to the dialog box.
If the user clicks OK or presses ENTER, the InputBox function returns whatever is in the text box. If the user clicks Cancel, the function returns a zero-length string ("").

The following example uses the InputBox function to display an input box and assign the string to the variable Input:

Dim Input
Input = InputBox("Enter your name")
MsgBox ("You entered: " & Input)

whammy
03-26-2003, 01:33 AM
Whoa... after reading all of these posts, I'm totally confused. :eek:

Can you explain in English (as I'm sure your boss doesn't understand programming) what HE wants? ;)

Actually you should be able to accomplish this (re-reading the post) using ASP server-side and javascript client-side, but can you give me the order in which everything is supposed to happen? :p

glenngv
03-26-2003, 01:59 AM
Originally posted by Mhtml
Why no instead of response.redirect, use response.write?

Eg;
If userLoggedIn <> "no" Then
theUrl = "logsuccess.asp"
Else
theUrl = "logfailure.asp"
End If
response.write("<script>parent.location='"&theUrl&"';window.close;</script>")


Use something like that..

PS: I'm not actually sure about the javascript in that example, I haven't worked with parent windows so it could be wrong. :confused:

response.write("<script>opener.location='"&theUrl&"';window.close;</script>")

but I'd rather make it in the same window (not on popup) as others suggested.