Simpler Hello ASP

Actually, for such a simple ASP page like the one we developed in the previous post, using a separate C# file is a bit of an overkill.

We could have instead add to the ASP page just the C# script fragment we need. If we ask to the wizard not to add a separate file for the C# code, we get a slimmer page, that we could easily modify to add our code in a specific script tag.

Here is an ASP page doing exactely the same job of the previous example:

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
myTime.Text = DateTime.Now.ToString();

<html xmlns="">
<head runat="server">
<title>Hello Even Simpler</title>
<form id="form1" runat="server">
Hello from Even Simpler. Current time is <asp:Label id="myTime" runat="server"/>

No comments:

Post a Comment