Hello. There is such a question on ASP.NET MVC. Here is my view:
@model MvcApplication4.Models.Class1 @{ Layout = null; } <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width" /> <title>Index</title> </head> <body> <div> @Html.EditorFor(x => x.Stroka1) @Html.EditorFor(x => x.Stroka2) @Html.EditorFor(x => x.Stroka3) @Html.DisplayFor(x => x.Stroka1)<br /> @Html.DisplayFor(x => x.Stroka2)<br /> @Html.DisplayFor(x => x.Stroka3)<br /> </div> </body> </html> Here is the action method:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace MvcApplication4.Controllers { public class HomeController : Controller { // // GET: /Home/ public ActionResult Index(string Stroka1, string Stroka2, string Stroka3) { return View(); } } } Well, the model itself:
public class Class1 { public string Stroka1 { get; set; } public string Stroka2 { get; set; } public string Stroka3 { get; set; } } The question is why, when requesting this type:
http: // localhost: 5669 / home / index? Stroka1 = Pavel & Stroka2 = Gleb & Stroka3 = Sergey
only the Html.EditorFor view fields are Html.EditorFor , and Html.DisplayFor displayed empty. As far as I understand, when requesting this type, an object of the Class1 model is Class1 and accordingly everything should be displayed. But only input fields are displayed, but not display. Where am I wrong, please tell me? On the other hand, in the Index action method, no model is passed to the View() method at all, then it turns out that the display should be completely without this data from the query. But for some reason, everything happens unexpectedly.