Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ASP/VBScript Navigation problem

Posted on 1998-11-24
4
Medium Priority
?
216 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 80 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
The viewer will learn how to count occurrences of each item in an array.
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).
Suggested Courses

971 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