Solved

ASP/VBScript Navigation problem

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Accessibility and Usability are two concepts that seem to be closely related.  But, too many people seem to have a distorted perception of them. During last five years, those two words have come to the day-to-day work of almost every web develope…
Read about why website design really matters in today's demanding market.
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now