Views - Design and development of web-applications

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.

The interaction of the controller with the engines of representations

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!

Other services that we offer

If you don’t see the necessary subject, paper type, or topic in our list of available services and examples, don’t worry! We have a number of other academic disciplines to suit the needs of anyone who visits this website looking for help.

How to ...

We made your life easier with putting together a big number of articles and guidelines on how to plan and write different types of assignments (Essay, Research Paper, Dissertation etc)