Business Website Links, LLC Company Logo

Visit us often.  Computer tips updated daily. Click here to--> "Tell a friend" so they can get updated computer tips, too.  Please visit our clients, as they support the computer tips page.

If you would like to submit a tip send us an email with your tip to


Business Website Links showing a picture of a sign with and Computer Tips for ASP Net belowASP Net Tips

Tip: ASP.NET Web Pages - Adding Razor Code

  • Razor Markup
  • Enter the code for Hello Web Page
    • /!DOCTYPE html>
    • /html lang="en">
    • /head>
      • /meta charset="utf-8" />
      • /title>Web Pages Demo
    • /head>
    • /body>
    • /h1>Hello Web Pages
    • /p>The time is @DateTime.Now

    • /body>
    • /html>
    • When entering the code replace the / with < in front"
  • After the code is entered run the example
  • The page above contains both ordinary HTML markup and Razor markup.
  • Razor Syntax for C#
    • C# code blocks are enclosed in @{ ... }
    • Inline expressions (variables or functions) start with @
    • Code statements end with semicolon
    • Variables are declared with the var keyword
    • Strings are enclosed with quotation marks
    • C# code is case sensitive
    • C# files have the extension .cshtml
  • C# Example
    • @{ var myMessage = "Hello World"; }
    • The value of myMessage is: @myMessage

    • @{
    • var greeting = "Welcome to our site!";
    • var weekDay = DateTime.Now.DayOfWeek;
    • var greetingMessage = greeting + " Today is: " + weekDay;
    • }
    • The greeting is: @greetingMessage

  • After the code is entered run the example
  • Razor Syntax for VB
    • VB code blocks are enclosed in @Code ... End Code
    • Inline expressions (variables or functions) start with @
    • Variables are declared with the Dim keyword
    • Strings are enclosed with quotation marks
    • VB code is not case sensitive
    • VB files have the extension .vbhtml
  • VB Example
    • @Code dim myMessage = "Hello World" End Code
    • The value of myMessage is: @myMessage

    • @Code
    • dim greeting = "Welcome to our site!"
    • dim weekDay = DateTime.Now.DayOfWeek
    • dim greetingMessage = greeting & " Today is: " & weekDay
    • End Code
    • The greeting is: @greetingMessage

  • After the code is entered run the example
  • More About C# and Visual Basic
  • If you want to learn more about Razor, and the C# and Visual Basic programming languages:
  • Go to the Razor section of this tutorial.
  • Tip: ASP.NET Web Pages - Intro

    • Easy Learning with "Run Example"
    • Enter the code for Hello Web Page
      • html>
      • body>
      • h1>Hello Web Pages
      • p>The time is @DateTime.Now

      • /body>
      • /html>
      • When entering the code "html> be sure to enter < in front"
    • After the code is entered run the example
    • ASP.NET Web Pages
    • Web Pages is one of many programming models for creating ASP.NET web sites and web applications.
    • Web Pages provides an easy way to combine HTML, CSS, and server code:
      • Easy to learn, understand, and use
      • Uses an SPA application model (Single Page Application)
      • Similar to PHP and Classic ASP
      • VB (Visual Basic) or C# (C sharp) scripting languages
    • In addition, Web Pages applications are easily extendable with programmable helpers for databases, videos, graphics, social networking and more.
    • Web Pages Tutorial
    • If you are new to ASP.NET, Web Pages is a perfect place to start.
    • In this Web Pages tutorial you will learn how to combine HTML, CSS, JavaScript and server code, using server code written in VB or C#.
    • You will also learn how to extend your web pages with programmable Web Helpers.
    • Web Pages Examples
    • Learn by examples!
    • Because ASP.NET code is executed on the server, you cannot view the code in your browser. You will only see the output as plain HTML.
    • At W3Schools every example displays the hidden ASP.NET code. This makes it easier for you to understand how it works.
    • Web Pages Examples
    • Web Pages References
    • At the end of this tutorial you will find a complete set of ASP.NET references with objects, components, properties and methods.
    • Web Pages References

    Tip: ASP.NET Classic ASP - Active Server Pages

    • Active Server Pages (ASP), also known as Classic ASP, was introduced in 1998 as Microsoft's first server side scripting engine.
    • ASP is a technology that enables scripts in web pages to be executed by an Internet server.
    • ASP pages have the file extension .asp, and are normally written in VBScript.
    • Visit Classic ASP Tutorial

    Tip: ASP.NET MVC

    • ASP.NET MVC is a framework for building large, scalable, standards-based web applications using well-established design patterns and the power of ASP.NET and the .NET Framework.
    • Visual Studio Express provides a free development tool that makes MVC development easy.
    • Start learning ASP.NET with MVC now!

    Tip: ASP.NET Web Forms

    • With ASP.NET Web Forms you use drag-and-drop design to build dynamic event-driven websites.
    • Choose from hundreds of controls and components to rapidly build user-driven sites with full data access.
    • Microsoft Visual Studio Express provides a free development tool that makes Web Forms development easy.

    Tip: ASP.NET Web Pages

    • ASP.NET Web Pages and the new Razor syntax provide a fast and lightweight way to combine server code with HTML to create dynamic web content.
    • You can connect to databases, add video and graphics, include social networking and add many more features using the latest web standards.
    • Microsoft WebMatrix is a free development tool that makes Web Pages development easy.
    • Start learning ASP.NET with Razor now!

    Tip:ASP.NET is a framework for building web sites and web applications. It supports three approaches to build web sites:

    • Web Pages
    • Web Forms
    • MVC

    Tip: Visual Web Developer

    • Visual Web Developer is a full-featured development environment for creating ASP.NET Web applications. Visual Web Developer offers you the following features:
      • Web page design A powerful Web page editor that includes WYSIWYG editing and an HTML editing mode with IntelliSense and validation.
      • Page design features Consistent site layout with master pages and consistent page appearance with themes and skins.
      • Code editing A code editor that enables you to write code for your dynamic Web pages in Visual Basic or C#. The code editor includes syntax coloration and IntelliSense.
      • Testing and Debugging A local Web server for testing and a debugger that helps you find errors in your programs.
      • Deployment Tools to automate typical tasks for deploying a Web application to a hosting server or a hosting provider.
    • For more information, see Visual Web Developer Content Map.
    • Testing and Debugging
    • Visual Web Developer provides an ideal environment in which to build Web sites and then publish them to a hosting site. Using the development tools in Visual Web Developer, you can develop ASP.NET Web pages on your own computer. Visual Web Developer includes a local Web server that provides all the features you need to test and debug ASP.NET Web pages, without requiring Internet Information Services (IIS) to be installed.
    • When your site is ready, you can publish it to the host computer using the built-in Copy Web tool, which transfers your files when you are ready to share them with others. Alternatively, you can precompile and deploy a Web site by using the Build Web Site command. The Build Web Site command runs the compiler over the entire Web site (not just the code files) and produces a Web site layout that you can deploy to a production server.
    • NOTE: The Build Web Site feature is not available in Visual Web Developer Express Edition.
    • Finally, you can take advantage of the built-in support for File Transfer Protocol (FTP). Using the FTP capabilities of Visual Web Developer, you can connect directly to the host computer and then create and edit files on the server.

    Tip: ASP.NET Overview

    • ASP.NET is a unified Web development model that includes the services necessary for you to build enterprise-class Web applications with a minimum of coding. ASP.NET is part of the .NET Framework, and when coding ASP.NET applications you have access to classes in the .NET Framework. You can code your applications in any language compatible with the common language runtime (CLR), including Microsoft Visual Basic and C#. These languages enable you to develop ASP.NET applications that benefit from the common language runtime, type safety, inheritance, and so on.
      • If you want to try ASP.NET, you can install Visual Web Developer Express using the Microsoft Web Platform Installer, which is a free tool that makes it simple to download, install, and service components of the Microsoft Web Platform. These components include Visual Web Developer Express, Internet Information Services (IIS), SQL Server Express, and the .NET Framework. All of these are tools that you use to create ASP.NET Web applications. You can also use the Microsoft Web Platform Installer to install open-source ASP.NET and PHP Web applications.

    Tip: Use the Visual Studio .NET Toolbox to add <div> elements to Web pages (ASP.NET)

    • If you need to add <div> elements to your ASP.NET Web pages, Visual Studio .NET makes it easy for you to do so on your ASPX design page. Simply open the VS .NET Toolbox and expand the HTML menu. Then, you can either select Grid Layout.