The structure is View - > Controller - > Model I work with 3 layers but it is not MVC. What does this passage mean?
@{
ViewBag.Title = "Index";
}
What is ActionResult? Do not have Page_Load? I'm lost. Can anyone help me?
The structure is View - > Controller - > Model I work with 3 layers but it is not MVC. What does this passage mean?
@{
ViewBag.Title = "Index";
}
What is ActionResult? Do not have Page_Load? I'm lost. Can anyone help me?
ASP.NET MVC has a very different concept than what you are accustomed to with webforms. There is no concept of page .aspx
, that is, a URL no longer refers to a particular file on the site.
When you create your first project. Visual Studio creates for you a HomeController
, a class inherited from Controller
.
This class has a method called Index
which returns a ActionView
.
Home / Index are the controller and default method that are invoked if you do not request anything different ( //localhost:60253/Home/Index
, //localhost:60253/Home
, //localhost:60253
give it anyway).
We are called the Index method of Controller Home.
This method in turn returns a View.
By default, the view is index.cshtml
of the /Views/Home
folder
ViewBag is a collection of values that can be passed from the controller to the View.
Example:
public ActionResult Index()
{
ViewBag.Mensagem = "Olá Mundo";
return View();
}
Allows you to show this content on your page (index.cshtml)
<body>
Mensagem: @ViewBag.Mensagem
</body>
E
@{
ViewBag.Title = "Index";
}
I would change the value of the ViewBag Title attribute to "Index", which might change the title of your page if your cshtml had this code:
<title>@ViewBag.Title</title>
I need to create an element (span, possibly) that will contain a character (initial letter of the name) and this element must have the rounded corners.
I was able to do it precariously, because depending on the letter, the shape of the element is no longer an exact round. What is the best way to do this?
Below is an example of what I need.