Home  >  Article  >  Backend Development  >  Share ASP.NET study notes (12) Introduction to Razor

Share ASP.NET study notes (12) Introduction to Razor

零下一度
零下一度Original
2017-05-27 16:04:531491browse

ASP.NET Razor - Tags

Razor is not a programming language. It is a server-side markup language.

What is Razor?

Razor is a markup syntax that allows you to embed server-based code (Visual Basic and C#) into web pages.

Server-based code creates dynamic web content as the web page is delivered to the browser. When a web page is requested, the server executes the server-based code in the page before returning the page to the browser. Run by the server, the code can perform complex tasks, such as accessing a database.

Razor is based on ASP.NET and is designed for creating web applications. It has the functionality of traditional ASP.NET, but is easier to use and easier to learn.

Razor Syntax

Razor uses a similar syntax to PHP and classic ASP.

Razor:

<ul>
@for (int i = 0; i < 10; i++) {
<li>@i</li>
}
</ul>

PHP:

<ul>
<?php 
for ($i = 0; $i < 10; $i++) {
echo("<li>$i</li>");
} 
?>
</ul>

Web Forms (Classic ASP):

<ul>
<% for (int i = 0; i < 10; i++) { %>
<li><% =i %></li>
<% } %>
</ul>

Razor Helper

ASP.NET Helpers are components accessible with a few lines of simple Razor code.

You can build your own helper using Razor syntax, or use the built-in ASP.NET helper.

Here are brief descriptions of some useful Razor helpers:

Web Grid

Web Graphics

Google Analytics

Facebook Integration

Twitter Integration

Sending Email

Validation Verification)

Razor Programming Language

Razor supports C# (C sharp) and VB (Visual Basic).

【Related recommendations】

1. ASP.NET free video tutorial

2. Share ASP.NET study notes (1) --WebPages Razor

3. Share ASP.NET study notes (2)--WebPages introduction

4. Use the Razor engine to generate static Detailed explanation of page (ASP.NET MVC) examples

5. [ASP.NET MVC Mavericks Road]03 - Razor syntax

The above is the detailed content of Share ASP.NET study notes (12) Introduction to Razor. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn