468,719 Members | 1,738 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,719 developers. It's quick & easy.

Who can help me? My fist Asp paga, doesnt work

Wen
Hi everyone,
..After my first lesson, I have to create a asp page with:
..asp tag for time
..client script that runs at the server for date
..client script that runs at client and shows a messagebox
These are my code, but it doenst work. Can someone help me?

<html>
<head>
<title>18 Nov 2004 My first ASP page</title>
</head>
<body>
<script language="javascript" runat="server">
var d = new Date()
var dd = d.getDate()
var mm = d.getMonth()
var yyyy = d.getFullYear();
var datum = dd + "-" + mm + "-" + yyyy
</script>

<script language="javascript">
alert("<% = Time %> " + " on " + datum)
</script>
</body>
</html>

Thanks at advance
Wen
Jul 22 '05 #1
7 1387
What message are you getting?

"Wen" <we**********************@hccnet.nl> wrote in message
news:cn**********@news.cistron.nl...
Hi everyone,
.After my first lesson, I have to create a asp page with:
.asp tag for time
.client script that runs at the server for date
.client script that runs at client and shows a messagebox
These are my code, but it doenst work. Can someone help me?

<html>
<head>
<title>18 Nov 2004 My first ASP page</title>
</head>
<body>
<script language="javascript" runat="server">
var d = new Date()
var dd = d.getDate()
var mm = d.getMonth()
var yyyy = d.getFullYear();
var datum = dd + "-" + mm + "-" + yyyy
</script>

<script language="javascript">
alert("<% = Time %> " + " on " + datum) </script>
</body>
</html>

Thanks at advance
Wen

Jul 22 '05 #2
datum is a server-side variable, so you need to write it into your HTML in
order for it to appear at the client. And you'll actually be writing the
variable's value, not the variable. The browser will not have any idea what
"datum" is, since that variable exists at the server level.

alert("<%=datum%>");

Ray at work

"Wen" <we**********************@hccnet.nl> wrote in message
news:cn**********@news.cistron.nl...
Hi everyone,
.After my first lesson, I have to create a asp page with:
.asp tag for time
.client script that runs at the server for date
.client script that runs at client and shows a messagebox
These are my code, but it doenst work. Can someone help me?

<html>
<head>
<title>18 Nov 2004 My first ASP page</title>
</head>
<body>
<script language="javascript" runat="server">
var d = new Date()
var dd = d.getDate()
var mm = d.getMonth()
var yyyy = d.getFullYear();
var datum = dd + "-" + mm + "-" + yyyy
</script>

<script language="javascript">
alert("<% = Time %> " + " on " + datum)
</script>
</body>
</html>

Thanks at advance
Wen

Jul 22 '05 #3
Exactly as your words. I've got a error "datum not define". But how do I put
the variable's value to alert box?
Best Regards
Wen
"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> schreef in
bericht news:%2****************@TK2MSFTNGP12.phx.gbl...
datum is a server-side variable, so you need to write it into your HTML in
order for it to appear at the client. And you'll actually be writing the
variable's value, not the variable. The browser will not have any idea
what "datum" is, since that variable exists at the server level.

alert("<%=datum%>");

Ray at work

"Wen" <we**********************@hccnet.nl> wrote in message
news:cn**********@news.cistron.nl...
Hi everyone,
.After my first lesson, I have to create a asp page with:
.asp tag for time
.client script that runs at the server for date
.client script that runs at client and shows a messagebox
These are my code, but it doenst work. Can someone help me?

<html>
<head>
<title>18 Nov 2004 My first ASP page</title>
</head>
<body>
<script language="javascript" runat="server">
var d = new Date()
var dd = d.getDate()
var mm = d.getMonth()
var yyyy = d.getFullYear();
var datum = dd + "-" + mm + "-" + yyyy
</script>

<script language="javascript">
alert("<% = Time %> " + " on " +
datum)
</script>
</body>
</html>

Thanks at advance
Wen


Jul 22 '05 #4
You'd do that just as I included in my previous reply. What you're looking
to do is take the value of a server-side variable, and write it to the HTML
of the page, whether that be actually in a javascript function, or in a div,
or in the <title> tag, it's all the same.

<title><%=datum%></title>
<div>Here's the value of the variable from the server: <%=datum%></div>
<script type="text/javascript">alert('<%=datum%>');</script>

Ray at work

"Kees Hoogendijk" <ni********@haalditweg-hcopleidingen.nl> wrote in message
news:cn**********@news.cistron.nl...
Exactly as your words. I've got a error "datum not define". But how do I
put the variable's value to alert box?
Best Regards
Wen
"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> schreef in
bericht news:%2****************@TK2MSFTNGP12.phx.gbl...
datum is a server-side variable, so you need to write it into your HTML
in order for it to appear at the client. And you'll actually be writing
the variable's value, not the variable. The browser will not have any
idea what "datum" is, since that variable exists at the server level.

alert("<%=datum%>");

Ray at work

"Wen" <we**********************@hccnet.nl> wrote in message
news:cn**********@news.cistron.nl...
Hi everyone,
.After my first lesson, I have to create a asp page with:
.asp tag for time
.client script that runs at the server for date
.client script that runs at client and shows a messagebox
These are my code, but it doenst work. Can someone help me?

<html>
<head>
<title>18 Nov 2004 My first ASP page</title>
</head>
<body>
<script language="javascript" runat="server">
var d = new Date()
var dd = d.getDate()
var mm = d.getMonth()
var yyyy = d.getFullYear();
var datum = dd + "-" + mm + "-" + yyyy
</script>

<script language="javascript">
alert("<% = Time %> " + " on " +
datum)
</script>
</body>
</html>

Thanks at advance
Wen



Jul 22 '05 #5
Wen
Hi Ray,
Thank you so much!! It works.
Best regards.
Wen

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:ut**************@TK2MSFTNGP11.phx.gbl...
You'd do that just as I included in my previous reply. What you're looking to do is take the value of a server-side variable, and write it to the HTML of the page, whether that be actually in a javascript function, or in a div, or in the <title> tag, it's all the same.

<title><%=datum%></title>
<div>Here's the value of the variable from the server: <%=datum%></div>
<script type="text/javascript">alert('<%=datum%>');</script>

Ray at work

"Kees Hoogendijk" <ni********@haalditweg-hcopleidingen.nl> wrote in message news:cn**********@news.cistron.nl...
Exactly as your words. I've got a error "datum not define". But how do I
put the variable's value to alert box?
Best Regards
Wen
"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> schreef in bericht news:%2****************@TK2MSFTNGP12.phx.gbl...
datum is a server-side variable, so you need to write it into your HTML
in order for it to appear at the client. And you'll actually be writing the variable's value, not the variable. The browser will not have any
idea what "datum" is, since that variable exists at the server level.

alert("<%=datum%>");

Ray at work

"Wen" <we**********************@hccnet.nl> wrote in message
news:cn**********@news.cistron.nl...
Hi everyone,
.After my first lesson, I have to create a asp page with:
.asp tag for time
.client script that runs at the server for date
.client script that runs at client and shows a messagebox
These are my code, but it doenst work. Can someone help me?

<html>
<head>
<title>18 Nov 2004 My first ASP page</title>
</head>
<body>
<script language="javascript" runat="server">
var d = new Date()
var dd = d.getDate()
var mm = d.getMonth()
var yyyy = d.getFullYear();
var datum = dd + "-" + mm + "-" + yyyy </script>

<script language="javascript">
alert("<% = Time %> " + " on " +
datum)
</script>
</body>
</html>

Thanks at advance
Wen



Jul 22 '05 #6
"Wen" <we**********************@hccnet.nl> wrote in message
news:cn**********@news.cistron.nl...
Hi everyone,
.After my first lesson, I have to create a asp page with:
.asp tag for time
.client script that runs at the server for date
.client script that runs at client and shows a messagebox
These are my code, but it doenst work. Can someone help me?

<html>
<head>
<title>18 Nov 2004 My first ASP page</title>
</head>
<body>
<script language="javascript" runat="server">
var d = new Date()
var dd = d.getDate()
var mm = d.getMonth()
var yyyy = d.getFullYear();
var datum = dd + "-" + mm + "-" + yyyy
</script>

<script language="javascript">
alert("<% = Time %> " + " on " + datum)
</script>
</body>
</html>

Thanks at advance
Wen


What do you call the file name? Where do you save it? How are you trying
to run/view it?
Jul 22 '05 #7
Wen wrote:
Hi Ray,
Thank you so much!! It works.


Not quite. JScript uses 0-based months, so you may want to use d.getMonth()
+ 1.

ALSO -- A note of caution: This only works because the default server-side
language is VBScript. I know this because you are mixing <script
runat=server> with <%%> blocks, and there is an order of operations. To see
this in action, move your server-side JScript block to the very end of your
script, and you'll note that it still works:
<script language="javascript">
alert("<%=Time%> on <%=datum%>")
</script>

<script language="JScript" runat="server">
var d = new Date()
var dd = d.getDate()
var mm = d.getMonth()
var yyyy = d.getFullYear();
var datum = dd + "-" + mm + "-" + yyyy
</script>

A far better approach to mixing languages on the server is to encapsulate
those elements into functions (or Subs). Either of those can be called from
any other block, regardless of the parsing order. Example:

<script language="javascript">
alert("<%=Time%> on <%=getDate()%>")
</script>

<script language="JScript" runat="server">
function getDate() {
var d = new Date()
return d.getDate() + "-" +
d.getMonth() + "-" +
d.getFullYear()
}
</script>
--
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. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 22 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by abcd | last post: by
11 posts views Thread by Goonigooguu | last post: by
2 posts views Thread by Simon Harvey | last post: by
36 posts views Thread by felixnielsen | last post: by
4 posts views Thread by placid | last post: by
8 posts views Thread by [rob desbois] | last post: by
8 posts views Thread by wastedhello | last post: by
1 post views Thread by Oskars | last post: by
9 posts views Thread by bryonone | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.