473,240 Members | 1,608 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,240 software developers and data experts.

tutorial help

Referring to this page:
http://msconline.maconstate.edu/tuto...3/asp03-06.asp

The "logon.asp" file writes "Incorrect Password" to Message.

Later, in the html body, the tutorial tries to access this string using
<%=Msg%>

Questions about this:

Q1. Doesn't Message have to be declared?

Q2. How and where should Message be declared so that it is guaranteed to be
available later in the html?

Q3. Is <%=Msg%a typo? Msg is not the same as Message, is it? Shouldn't it
be <%=Message%>?

Q4. If I want to look up the syntax of writing ASP, what language would I
look under? Is it equivalent to VB6?

Thanks,
~Joe
Aug 7 '07 #1
3 1485
jp2code wrote:
Referring to this page:
http://msconline.maconstate.edu/tuto...3/asp03-06.asp

The "logon.asp" file writes "Incorrect Password" to Message.

Later, in the html body, the tutorial tries to access this string
using <%=Msg%>

Questions about this:

Q1. Doesn't Message have to be declared?
Variables only have to be declared if the Option Explicit directive
appears at the beginning of the script.
>
Q2. How and where should Message be declared so that it is guaranteed
to be available later in the html?
Message is a server-side variable. It will never be available to the
html. Server-side code generates html - that's pretty much all it does.
Once the html is sent to the client, the server-side code, including
variables, is out of of the picture.

The only way to pass the value of a server-side variable to the html is
to write it to Response, as this code does. If you have client-side code
and you want to have a client-side variable that contains the value of
the server-side variable, again, the value needs to be written to
Response, like this:

<html>
<script type="text/javascript">
var Message="<%=Message%>"
alert(Message)
</script>

In vbscript, variables can be declared anywhere in the script block.
When compiled, the variable declarations are "hoisted" to the beginning
of the script block.
Experienced developers tend to declare their variables at the beginning
of the script.
>
Q3. Is <%=Msg%a typo? Msg is not the same as Message, is it?
Shouldn't it be <%=Message%>?
Yes, it's a typo. Without Option Explicit, you will not get an error:
just nothing written into the html.
>
Q4. If I want to look up the syntax of writing ASP, what language
would I look under? Is it equivalent to VB6?
ASP is not a language. It is a "platform" that allows the use of several
scripting languages. Most examples are written in vbscript, but there
are those who swear by using javascript.

http://msdn2.microsoft.com/en-us/library/ms675532.aspx

http://www.microsoft.com/downloads/d...DisplayLang=en

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Aug 7 '07 #2
"jp2code" wrote:
Q1. Doesn't Message have to be declared?
Not unless [Option Explicit] is declared:
http://msdn2.microsoft.com/en-us/library/bw9t3484.aspx
Q2. How and where should Message be declared so that it is
guaranteed to be available later in the html?
Oddly enough, your variables can be declared anywhere in the script that has
the same scope. You can even declare them after you use them.
http://blogs.msdn.com/ericlippert/ar...18/159378.aspx

Q3. Is <%=Msg%a typo? Msg is not the same as Message, is it?
Shouldn't it be <%=Message%>?
Your understanding of the problem is correct.

Q4. If I want to look up the syntax of writing ASP, what language
would I look under? Is it equivalent to VB6?
ASP can be written in any number of languages. By default, IIS supports
JScript and VBScript.

JScript: http://msdn2.microsoft.com/en-us/library/yek4tbz0.aspx
vbscript: http://msdn2.microsoft.com/en-us/library/d1wf56tt.aspx
ASP: http://msdn2.microsoft.com/en-us/library/ms524716.aspx
--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.

Aug 7 '07 #3
jp2code wrote on 07 aug 2007 in microsoft.public.inetserver.asp.general:
Referring to this page:
http://msconline.maconstate.edu/tuto...3/asp03-06.asp

The "logon.asp" file writes "Incorrect Password" to Message.

Later, in the html body, the tutorial tries to access this string
using <%=Msg%>

Questions about this:

Q1. Doesn't Message have to be declared?

Q2. How and where should Message be declared so that it is guaranteed
to be available later in the html?

Q3. Is <%=Msg%a typo? Msg is not the same as Message, is it?
Shouldn't it be <%=Message%>?

Q4. If I want to look up the syntax of writing ASP, what language
would I look under? Is it equivalent to VB6?
You are completely right. The code is terrible:
================================================== ===
<%
If Request.Form("SubmitButton") = "Submit" Then

If Request.Form("Password") = "xyzzy" Then
So there is no test if "Account" is correct
Response.Redirect("welcome.asp")
Else
The else is nonsense, since the redirect has already taken away the other
possibility
Message = "Incorrect Password"
Should be Msg = ...
Also: the first pass the variable msg is undeclared!!!!
End If

End If
%>
[..]
<span style="color:red"<%=Msg%</span>
The spaces around the <%%are useless, methinks.

================================================== =====

I would suggest this:

===================================
<% ' vbscript [in examples always name the asp language used]

Option Explicit ' if you are inclined to such things
Dim Msg ' if you are inclined to such things

If Request.Form("Account") = "myName" AND_
Request.Form("Password") = "xyzzy" Then
Response.Redirect("welcome.asp")
End If

Msg = ""
If Request.Form("SubmitButton") = "Submit" Then
Msg = "<span style='color:red;'>Incorrect Password</span><br>"
End If

%>

<html>
<body>
<h3>Logon Page</h3>

<form action="logon.asp" method="post">
Account: <input type="text" name="Account" size="10">
<br>Password: <input type="password" name="Password" size="10">
<br><%=Msg%><input type="submit" name="SubmitButton" value="Submit">
</form>

</body>
</html>
===================================


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Aug 7 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Earth | last post by:
Dear all, I am new in Portlet and reading the JetSpeed tutorial. However, I have difficulties to follow the JetSpeed tutorial point 6 and 7 in...
3
by: Adolfo | last post by:
Hello everyone, I am a newbie starting Fredrik Lundh .pdf tutorial. Running W2000. I am stuck in page four "Hello Again" program: When I try running it, it shows the root Python window very fast...
33
by: Xah Lee | last post by:
i've started to read python tutorial recently. http://python.org/doc/2.3.4/tut/tut.html Here are some quick critique: quick example: If the input string is too long, they don't truncate it,...
0
by: Guennadi V. Vanine | last post by:
I followed IIS ASP Tutorial examples on isolated from net Windows XP Professional available at http://localhost/iishelp/iis/htm/asp/AspTut02.htm In order to run DisplayAds.asp the example on...
6
by: Verne | last post by:
I was just wondering if anyone else is using this program in the Enterprise edition as I'm a little disgusted with the Tutorial on the Editor. Worked fine withe the exception that one line of code...
15
by: JS | last post by:
I have used google and searched for gcc tutorial but have not found anything usefull yet. Does somebody know a good link to a gcc tutorial? JS
4
by: Bob hotmail.com> | last post by:
Everyone I have been spending weeks looking on the web for a good tutorial on how to use regular expressions and other methods to satisfy my craving for learning how to do FAST c-style syntax...
11
by: Magnus Lycka | last post by:
While the official Python Tutorial has served its purpose well, keeping it up to date is hardly anyones top priority, and there are others who passionately create really good Python tutorials on...
9
by: julie.siebel | last post by:
Hello all! As embarrassing as it is to admit this, I've been designing db driven websites using javascript and vbscript for about 6-7 years now, and I am *horrible* at form validation. To be...
31
by: Antoon Pardon | last post by:
The following is part of the explanation on slices in the tutorial: The best way to remember how slices work is to think of the indices as pointing between characters, with the left edge of the...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.