Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #11 (permalink)  
Old June 22nd, 2004, 01:13 AM
Friend of Wrox
Points: 2,376, Level: 20
Points: 2,376, Level: 20 Points: 2,376, Level: 20 Points: 2,376, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Australia.
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

qazi_nomi,

Javascript is one solution I guess but a server side solution would be prefered as you need to validate any data that is saved to a database anyway.

A one page system would be much easier for your purpose.

Have the page submit to itself, test the data.
If ok, do your stuff and redirect to hte next page.
If not, continue loading the page with messages in place.

I'll give you the basic Idea in code here but there is a lot of things you can do with this basic structure.

Code:
<% @language = "vbscript"%>
<html>
<head>
    <title>Test Validate</title>
</head>
<body>
<%
Dim Message1, Message2

call Initialise()

%>
This is the form<BR>

<form method="POST" action="" name="frmMain" id="frmMain">
This is a field <input type="text" name="Test1" value="<%= request("Test1")%>"><%= Message1%> Correct Anwer(ANSWER1)<BR>
This is another field <input type="text" name="Test2" value="<%= request("Test2")%>"><%= Message2%> Correct Anwer(ANSWER2)<BR>
<BR>
When clicking this button the value of page action (The Hidden Box) is set to TEST
This allows the Validate function to execute.
<input type="submit" onclick="frmMain.PageAction.value='TEST';" name="Test">


<input type="hidden" name="PageAction" value="">
</form>
<%
    sub Initialise()
        'Do any Variable Initialisation here
        Message1 = ""
        Message2 = ""

        'Test if required
        If request("PageAction") = "TEST" then call Validate()


    end sub

    sub Validate()
        valid = true

        'Test the first value
        If Ucase(request("Test1")) <> "ANSWER1" then
            valid = false
            Message1 = " >> ERROR HERE"        
        end if

        'Test the second value
        If Ucase(request("Test2")) <> "ANSWER2" then
            valid = false
            Message2 = " >> ERROR HERE"        
        end if

        'If all valid then valid still equals true
        if valid then
            'DO some code to handle the data
            'blah blah blah 

            'Then redirect to the page you want to go
            response.redirect("AnotherPage.asp")
        else
            'Nothing to do
            'The page will load again with the correct values in place
        end if
    end sub
%>
</body>
</html>
======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
Reply With Quote
  #12 (permalink)  
Old June 22nd, 2004, 01:21 AM
Friend of Wrox
Points: 2,376, Level: 20
Points: 2,376, Level: 20 Points: 2,376, Level: 20 Points: 2,376, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Australia.
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Actually that was more or less the same as Happygv's suggestion.
What was wrong with that?

You can use client side aswell if you need. http://www.sitepoint.com/article/862?ct=1



======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
Reply With Quote
  #13 (permalink)  
Old June 22nd, 2004, 01:45 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Cochin, Kerala, India.
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

Hello Happygv,

I accept your suggestion. It is better to do it in one page. I can use include files to reduce the size of page.
Reply With Quote
  #14 (permalink)  
Old June 22nd, 2004, 02:00 AM
Friend of Wrox
Points: 1,288, Level: 14
Points: 1,288, Level: 14 Points: 1,288, Level: 14 Points: 1,288, Level: 14
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2004
Location: Stockholm, Sweden
Posts: 331
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to qazi_nomi
Default

Dear look at this when u fill a form on one pageand submit that page. Then if you BACK the page by
browser then the information you entered is there.
Is there any method to return the browser like this?

Love 4 all
Reply With Quote
  #15 (permalink)  
Old June 22nd, 2004, 02:10 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Cochin, Kerala, India.
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

Yes, there is. You can simply put it like this.

<script language="Javascript">
    window.history.back();
</script>

But this will work only if Javascript is enabled on client browser.

There are browsers like AOL, where JS is not enabled by default. Even in IE, it is not good to depend on JS as it can be disabled.

In big corporates etc, they will normally disable JS from browsers for fear of virus/hacking activities.

The best pages should not depend on JS, cookies and session.
Reply With Quote
  #16 (permalink)  
Old June 22nd, 2004, 02:20 AM
Friend of Wrox
Points: 1,288, Level: 14
Points: 1,288, Level: 14 Points: 1,288, Level: 14 Points: 1,288, Level: 14
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2004
Location: Stockholm, Sweden
Posts: 331
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to qazi_nomi
Default

Hows that if I use session variables for that and All information is first stored in
session variables then take any further actions and If action succeed then delete that
session variables

Love 4 all
Reply With Quote
  #17 (permalink)  
Old June 22nd, 2004, 02:30 AM
Friend of Wrox
Points: 2,376, Level: 20
Points: 2,376, Level: 20 Points: 2,376, Level: 20 Points: 2,376, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Australia.
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

You seem to be going arround in circles qazi_nomi.
The best method has been explained as asked, all others are possible but far form ideal.

Why not try the one page method?
I think you will find that you use it for all you pages from then on, it is a good method to use.

If you have any trouble with elements of it, feel free to ask more questions, but you should give it a go first.

======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
Reply With Quote
  #18 (permalink)  
Old June 22nd, 2004, 02:31 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Cochin, Kerala, India.
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

DEar Gazi_nomi,
There is nothing logically incorrect for doing this. Since the number of form elements is more,
You will need an equal number of session variables. The more the number of session variables,
the less will be the performance. It will affect not only your website, but the other sites hosted
on the server (If you use shared server for hosting the site).

If the number of registrations you expect is less, you may go for this.
Reply With Quote
  #19 (permalink)  
Old June 22nd, 2004, 02:37 AM
Friend of Wrox
Points: 2,376, Level: 20
Points: 2,376, Level: 20 Points: 2,376, Level: 20 Points: 2,376, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Australia.
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Madhukp,

Registrations are one thing, the rest of the site is another.
Even thought it is possible he should not use session variables.
He will end up using them for every form on every page, on any site he does.

The variables are accurately and reliably stored in the request object.
He should use the request object.
And preferrably on one page.

======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
Reply With Quote
  #20 (permalink)  
Old June 22nd, 2004, 03:06 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Cochin, Kerala, India.
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

I am always against the use of session variables for this purpose in web pages.

I am not understanding why he can't use the one page method suggested above. To suggest some other method only, I have told that he may use that method with the knowledge that it will reduce the performance.

gazi_nomi,
Once again, I am recommending the one page method suggested above by happygv.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Standalone validation + web form validation morbo Struts 0 August 19th, 2008 04:02 AM
Javascript validation not working in content page Manoj Bisht ASP.NET 2.0 Basics 0 March 3rd, 2008 02:21 AM
Validation using Validation Framework kalyangvd Struts 1 January 2nd, 2008 06:53 AM
Form Validation and Redirect Page jourys ASP.NET 1.0 and 1.1 Basics 1 February 24th, 2006 12:20 PM



All times are GMT -4. The time now is 09:06 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.