Solved

ASP/VBScript Navigation problem

Posted on 1998-11-24
4
211 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
  • 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

809 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