2.MVC Framework Development (View development----BASIC syntax)

Source: Internet
Author: User

1. Different from ordinary HTML, the data inside the controller cannot be displayed in HTML in normal HTML.

In the MVC framework, it provides a view template (which combines common HTML tags with the ability to display data from the controller)

View Template properties: He has his own set of grammar rules to display the data

In the pages in ASP. <%%> format to embed the C # language

In the MVC framework, the view also needs to be embedded in the C # language, and after MVC3.0 the unification is the Razor View Engine (template), starting with the @ Sign C # language

2.Razor View Syntax

Start with the @ symbol, if it is a program code, then use {}, if you want to output a variable in front of the variable with an @ symbol,

Like what:

@{            int;            @a  }

3. In razor, the notation of the annotation, if in @{} single-line comment with//

4. In HTML or razor, multiple lines of comments are used @* *@ this method

5. How to embed HTML code in razor, when the need to introduce a variable is directly the @ variable name,

For example, the drop-down list box outputs 1-100 of the EMBED code:

<select>               @{                   for (int i=1; i<=; i++)                   {                       <option value="@i">@i</option>                   }               }   </Select>

6. About the escape of razor, such as in JavaScript, there is an @ symbol in the regular expression, this time with the @@ 符号 to escape,

For example: var s =/^\[email protected]@$/;

The niche just learns, if has the mistake, also please pointing.

2.MVC Framework Development (View development----BASIC syntax)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.