ASP. NET MVC Learning view dynamic content and HtmlHelper

Source: Internet
Author: User

There are several 1 dynamic content views in the view. Inline Code2. Html Helper3. Section4.partial View 4.Child Action

Section

The Razor view engine supports separating part of the view so that it can be reused where it is needed, reducing the redundancy of the Code

section can only be in the current view or its LA

Called in the yout. @RenderSection method does not find the section specified by the parameter throws an exception

Partial View

Partial view is the partial Razor and Html tags that are placed in a separate view file for reuse in different places.

Create a new view file named Mypartial in the/views/shared directory, and tick "make as partial view"

There is no difference between Partial view and normal and view usage, or you can use strong typing, such as the type of model that we specify in mypartial.cshtml by @model:

Child Action

The child action is similar to Patial view and can be reused for the same sub-content in different parts of the application. The difference is that it renders the child content by invoking the action method in the controller, and typically contains the processing of the business

HtmlHelper extension methods

Table cell Helper Method

Take advantage of its HTML. BeginForm () and HTML. EndForm () constructs a simple form

  @Html. BeginForm ()  <label>userName</label> <input name=
   
     " 
    username  
    "  type=
     " 
    text  
     "/> <label>password</label> <input name=
    "  
    password  
     " Type=
     " 
    text  
    " / > <input type=
     " 
    submit  
    "  value=
     " 
    submit " Span style= "COLOR: #800000" > "/>
    @{html.endform ();}  
   

Another way of writing

  @Html. BeginForm () { <label>userName</label> <input name= " username  "  type= " text   "/> <label>password</label> <input name="  password   " Type= " text  " / > <input type= " submit  "  value= " submit " Span style= "COLOR: #800000" > "/>}  

ASP. NET MVC Learning view dynamic content and HtmlHelper

Related Article

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.