|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
CASE statements and passing arguments
I've been asked to help with some asp pages. Naturally I am like Sgt Schultz when it comes to vbscript or asp--"I know nothing."
I have a login page that calls another script based on the usertype. The login script sets a variable Session("User_Type"), does some cleanup, then redirects (correctly). So far, so good--I think. The second script validates the user before opening the page. It uses the variable Session("User_Type") in a case statement. The default is an error message. The following is the error message on opening the second page. Code:
Microsoft VBScript compilation error '800a0400'
Expected statement
/library/library.asp, line 7
select case Session("User_Type")
case "Admin", "FBR Employee", "Agent"
----------------------------------^
I suspect it is due to no statement in the matched case. I was looking for a break statement to kick out to the page HTML. Here is the library.asp code. Code:
<%@ Language = "VBScript" %>
<%
Option Explicit
'On Error Resume Next
Response.Expires = 0
select case Session("User_Type")
'how does script get variable?
case "Admin", "FBR Employee", "Agent"
'It is ok for this user to proceed and view this page
'shouldn't there be a statement here?
case else
'Error trap
%>
<html>
<head><title>Invalid Form Library Access</title>
</head>
<body>
<!-- error page html -->
</body>
</html>
<%
Response.End
end select
%>
<html>
<head>
<!-- regular page html -->
I don't see how Session("User_Type") gets sent to the script either. Just in case it will help, here is a snippet of login code. Code:
case "FBR Employee", "Agent"
'Set the session variable that will be needed to grant access to the admin
'and form library pages
Session("User_Type") = rsLogin("User_Type")
'Set the insert statement for this login attempt
if sqlInsertLogin <> "" then
conFBRWebDB.Execute(sqlInsertLogin)
end if
' Clean up before the redirect
rsLogin.Close
Set rsLogin = Nothing
conFBRWebDB.Close
Set conFBRWebDB = Nothing
Response.Redirect("library/library.asp")
I will certainly appreciate any help here. cheers, gary
__________________
There are those who manage to build a web site without knowing what they're doing; thereby proving to themselves they do, indeed, know what they're doing. My html and css workshop, demos and tutorials. Ask a better question, get a better answer. |
|
#2
|
||||
|
||||
|
Hi,
what does FBR Employee and Agent do? Are you trying to set these as variables? Kong. |
|
#3
|
||||
|
||||
|
Quote:
In the login script, these are possible values of rsLogin, the result of a db query. It is the tested value in the case statement. In the function block, this value is assigned to Session("User_Type"), which is the tested variable in the second script, library.asp. cheers, gary |
|
#4
|
||||
|
||||
|
Hi,
At the end of your case statment you don't have an action. ie your looking for three different names but your not finishing that particular line of the case. as a test you could try setting a dummy variable at the end to see if that works. ie: Code:
case "Admin", "FBR Employee", "Agent" Anyvariable=1 Kong. |
|
#5
|
||||
|
||||
|
Quote:
I think I mentioned that. Quote:
What would be the vbs equivalent of a "break" statement? I think what I need to do is simply break out of the case block and drop into the HTML. Additionally, how is the test variable passed to the second (library.asp) script? g |
|
#6
|
||||
|
||||
|
Can no one answer this? It looks to me like I need to simply break out of the conditional block and pick up the html that follows.
Unfortunately, I know no vbscript. Would an 'exit' statement exit the script, or just the block? Were this PHP, I would use something like this; PHP Code:
tnx, gary |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > CASE statements and passing arguments |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|