Views
Creation of the MVC-application answers are involved in the formation of HTML-code (view engine, view engine). The interaction between them and the controller is shown in Fig. 4.36.
The generated HTML response is described using view templates . View templates contain HTML code that can include C # or Visual Basic code. The standard view is very similar to an ordinary web page with a lot of HTML markup. However, it also has code insertions in C #. An example of a presentation template is shown in Fig. 4.40.
Fig. 4.36. Controller interaction with view engines
It should be noted that although the view mainly consists of HTML code, it is not an HTML page. When you compile an application based on a view template, you first generate a class in C #, and then compiles the class. The class that is created is derived from the WebViewPage class (if using the Razor engine) or the ViewPage class (if the ASPX engine is used).
The main rule for describing views is that the program code for the templates should not itself input data from external sources and perform any calculations (this should be done by the controller action methods), but should only describe the formation of the HTML response.
The description of the code for the presentation template can be specified using different syntaxes. In ASP.Net MVC, the ASP.Net Web Forms description syntax can be used by default (without using server controls, in files with the .aspx extension) and Razor syntax (in files with the extension .eshtml and vbhtml). To process templates that use different syntax, they create their own HTML-code generation systems (presentation engines). In ASP.Net MVC, two engines are enabled by default: ASPX and Razor.
To process a template by the view engine, it needs to transfer the name of the template file and the data that can be used to generate the HTML code. This is done using the View () method, which has many overloaded versions. For example:
• View () - generate an HTML response using a template that has the same name as the action method, and is stored in a subdirectory with a short controller name that is included in the Views folder; it does not accept data of a given type (model);
• View (string viewName) - generate an HTML response using a template with the specified name viewName;
• View (object Model) -forms an HTML response using a template that has the same name as the action method, but takes a Model object whose type is specified in the view template;
• View (string viewName, object Model) -forms an HTML response using a template with the specified name, which has the same name as the action method, but takes a Model object whose type is specified in the view template.
thematic pictures
Also We Can Offer!
Essay Writing
[...]
- Argumentative essay
- Best college essays
- Buy custom essays online
- Buy essay online
- Cheap essay
- Cheap essay writing service
- Cheap writing service
- College essay
- College essay introduction
- College essay writing service
- Compare and contrast essay
- Custom essay
- Custom essay writing service
- Custom essays writing services
- Death penalty essay
- Do my essay
- Essay about love
- Essay about yourself
- Essay help
- Essay writing help
- Essay writing service reviews
- Essays online
- Fast food essay
- George orwell essays
- Human rights essay
- Narrative essay
- Pay to write essay
- Personal essay for college
- Personal narrative essay
- Persuasive writing
- Write my essay
- Write my essay for me cheap
- Writing a scholarship essay
Case Study
[...]
Citation Style
[...]
Additional Services
[...]
CV
[...]
Assignment Help
[...]
Admission Services
[...]
Custom Paper
[...]