Vote count:
0
Should the Model, View or the Controller be the one that knows the page title?
Option 1
Use the model to store the page title (this makes the model more of a view-model):
public class SomeModel
{
string Title { get; set; }
}
Then the view can simply set the title accordingly
<title>@Model.Title</title>
Option 2
The view knows its own title:
@{
ViewBag.Title = "Some Title";
}
and somewhere in view or the default layout its being used:
<title>@ViewBag.Title</title>
Option 3
Set the title from the controller
ViewBag.Title = "Some Title"
And then use it from the view
<title>@ViewBag.Title</title>
Which is the best approach (assuming i have a common layout for the different pages) ?
asked 1 min ago
Aucun commentaire:
Enregistrer un commentaire