I am learning some aspx and had a question. I have the following example code:
<%@ Page Language="C#" %>
<html>
<body>
<form id="form1" runat="server">
Current server time is <% =GetTime()%>.
</form>
</body>
</html>
Now what i dont understand here is that if the form is running at server already, why do we need the <% %> code blocks again? Maybe im not understanding the distinction between the code blocks and the whole running at server on the page. Can anyone please clear up my misconceptions about what is happening here? I just dont really understand the serverside vs clientside terminology for an aspx page.
I have also seen code like this:
<script language="VB" runat="server">
Dim ....
Public Sub PageLoad()
...
Response.Write("Hello")
End Sub
</script>
<% If dataExists(whatever) Then %>
HelloWorld
Now why couldnt the codeblocks be eliminated above? I mean in the server tags, that code is already running server side and making some write requests. Then you have code blocks which are doing some logic check to write again. Why separate these? Arent they the same functionality or am i missing something?