Chapter 16: Web Pages Examples

WebPages Examples

This page is not a single lesson with new theory — it’s a collection of ready-to-run mini-examples that demonstrate almost everything you’ve learned so far in the WP Tutorial track.

W3Schools provides two separate tracks here:

  • Examples in C# (using .cshtml files with C# Razor syntax — most common and recommended today)
  • Examples in VB (using .vbhtml files with VB.NET Razor syntax — still supported, but less used now)

Both languages do the same things — the differences are mostly in syntax (C# uses ; and {} more like JavaScript/Java, VB uses End If, no ;, etc.).

The page groups examples into categories like:

  • Basic Web Pages
  • Forms Examples
  • Objects Examples
  • Files Examples
  • Databases Examples
  • Helpers Examples (WebGrid, Chart, etc.)
  • And more…

Each example has:

  • A short description
  • “Try it Yourself” button → opens editor with code
  • Separate tabs/links for C# version and VB version

Since the page itself doesn’t embed all code inline (it links to individual “showfile” pages), I’ll act as your teacher and walk you through key representative examples from the main categories — with both C# and VB side-by-side where meaningful differences exist.

1. Basic Examples – Hello World + Date/Time

Goal: Show simple Razor output, server time.

C# version (Default.cshtml or similar)

HTML

VB version (same file but .vbhtml extension)

HTML

Differences:

  • C#: Uses @{ … } and ends statements with ;
  • VB: Uses @Code … End Code, no ;, Dim for variables
  • Date: C# uses DateTime.Now, VB uses shortcut Now

2. Forms Example – Simple Input + Greeting

Goal: Postback form, read input.

C# version

HTML

VB version

HTML

Key differences:

  • VB uses If … Then … End If (multi-line) or @If … Then @<tag> Else @<tag> End If
  • No ; in VB
  • String concatenation in VB often uses & (but here not needed)

3. Database + WebGrid Example (Popular One)

Goal: Show products from DB in sortable/paged grid.

C# version (from Databases + WebGrid lessons)

HTML

VB version — almost identical, but syntax adjusted:

HTML

Differences:

  • VB uses := for named parameters
  • New WebGrid(…)
  • Function(item) instead of @<text>…</text> for format (VB lambda)

4. Layout + PageData Sharing Example

_Layout.cshtml (shared)

HTML

Content page (C#)

HTML

Content page (VB)

HTML

→ Page.Title is dynamic property bag — same in both languages.

5. Teacher Summary & Advice (2026 Style)

  • C# is dominant — 90%+ of examples/jobs/tutorials use C# (cleaner, more modern ecosystem)
  • VB still works — great if you come from Classic ASP/VBA background, but learn C# for future
  • W3Schools provides parallel examples so you can switch languages easily
  • All Razor rules ( @, @{ }, IsPost, Request, Database.Open, WebGrid, etc.) are identical — only language syntax changes

The “Examples” page is your playground — click “Try it Yourself” on each one, switch between C#/VB tabs, edit and run instantly.

Which example do you want to dive deeper into next?

  • A full login/register flow in both languages?
  • Chart or WebMail with C# vs VB differences?
  • Or ready to move to modern ASP.NET Core Razor Pages?

Your call, Webliance — you’re doing fantastic! 🚀🇮🇳 Happy coding! 😊

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *