Solved

ASP/VBScript Navigation problem

Posted on 1998-11-24
4
213 Views
Last Modified: 2013-12-25
When a user clicks on a button, based on a set of criteria
in either ASP/VBScript the user either continues to remain in the same screen or navigates to another screen. This is the functionality I want.
I don't know what code to write to navigate to another screen. Could someone please tell me how this could be done?
This is true in either VBScript (SCRIPT Tag) or ASP script
(<% .. %> tag).
0
Comment
Question by:sowmyan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 1

Accepted Solution

by:
rajgn earned 20 total points
ID: 1856694
Since you're not specific about your requirement. I'm giving an example code of a login page.
The page will have a form with two textfields and submit, reset buttons. If user submits the page, it'll check the credentials(may be with data from a database) then
1. if they're right, he's directed to some other page.
2. if not, error will be displayed in the same page asking him to try again.
Here's the code.

<%response.buffer = true%>
<html>
<head>
<title>Login page </title>
</head>
<body>
<%
if NOT IsEmpty(request("username"))  then    ' check whether it's first time
  user = request("username")
  pass =  request("passwd")
 'now connect to database or open a text file containing password info and check for  'correct input. Let's say you set a flag noError(not mandatory though)
 if noError then
   response.clear
   response.end
   response.redirect "nextPage.asp"
 else
   'display error message here
 end if
end if
%>
<form name="logForm" action="<%= request.ServerVariables("SCRIPT_NAME")%>" method="post">
Username : <INPUT TYPE="text" name="username" value="<%= request("username")%>">
Password: <INPUT TYPE="password" name="passwd">
<input type="submit" value="Submit">
<input type="reset" value="clear">
</form>
</body>
</html>
0
 
LVL 1

Expert Comment

by:rajgn
ID: 1856695
Small correction to my answer...

DELETE the line 'response.end'
0
 

Author Comment

by:sowmyan
ID: 1856696
I did try out the "redirect" command but did not use the "redirect.clear" syntax and consequently got some "http header" error.
Are there any other techniques of navigation other than "redirect"?
0
 
LVL 1

Expert Comment

by:rajgn
ID: 1856697
You can't redirect once the HTML headers are written. That's whay you're getting that error. You can get rid of this in two ways.
1. Redirect before writing any HTML tags on your page. OR
2. Do it in the similar way as I did in my answer.
For this first you've to Buffer the response by setting response.buffer = true (this will not send the response immediately to the browser until you say response.end or response.flush)

Then do whatever checking you want. In between if you decide to go to some other page, first clear the buffer by saying response.clear then redirect the page. You can say response.end after the redirect sentence.

Well, coming to other techniques of navigation, one can't go to some other page until it's requested(by submitting a form or clicking a hyperlink) or you're directed(like in our case). I don't think there're some other methods of redirecting using ASP.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question