ASP.Net - What's the #(hash) for or mean? - 04/05/2011

I've been doing ASP and ASP.Net for over 10 years now...and I still don't know much.

Take the following code example.

<script runat = "server">

dim mydate as datetime

sub page_load

end sub

</script>

<html>
<head>

<title>
Test
</title>

</head>
<body>

<% response.write(mydate) %>

</body>
</html>

If you view this page you will see the following

01/01/0001 00:00:00

Yet if we alter the page as below

<script runat = "server">

dim mydate as datetime

sub page_load

end sub

</script>

<html>
<head>

<title>
Test
</title>

</head>
<body>

<%# mydate %>

</body>
</html>

The page will simply come up blank.

This is the bit that has changed -

<% response.write(mydate) %>became<%# mydate %>

What is going on here? Being familiar with ASP as well as ASP.net the <% %> means this code is run as part of the page, where as <%# %> means speak this, do this. To be honest, I don't know. More research required...