Solved

ASP/VBScript Navigation problem

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
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.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

920 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

12 Experts available now in Live!

Get 1:1 Help Now