Don't you think that this is the second most trivial case of ASP.NET, following the most trivial case where you don't use server-side code at all, only HTML? All server-side Web technologies allow creation of pages from scratch. This is the most basic skill everyone should learn almost from the very beginning.
This is probably the simplest recipe I could think of:
Add a Web page to your ASP.NET Web project. Let's assume this is the very first page created from the project template called "Default.aspx". The code-behind server-side C# file will be "Default.aspx.cs".
Remove everything from "Default.aspx" except this:
<%@ Page Language="C#" CodeFile="Default.aspx.cs" Inherits="_Default" %>
In "Default.aspx.cs", you can write:
public partial class _Default : System.Web.UI.Page {
protected void Page_Load(object sender, System.EventArgs e) {
this.Response.Write("<html><body><h1>Hello, ASP.NET page from scratch!</h1></body><html>");
}
}
Are you getting the idea? Using
Response.Write
, you can render any content on your page, perform any required calculations using C# code in this class, other classes you may want create, other assemblies you may want to reference — anything at all. However, it's more practical to use at least HTML skeleton in your *.aspx pages and add server-side code using
<%@ ... %>
syntax where you need it.
—SA