Contact Form

Name

Email *

Message *

Cari Blog Ini

Ajax Post Example Javascript Aspnet

## ASP.NET Core MVC Model Binding - ViewData["Title"] ### Overview In ASP.NET Core MVC, ViewData is a dynamic property that provides a way to pass data from the controller to the view. ViewData["Title"] is a specific property that is used to set the title of the page that is rendered by the view. ### Setting the ViewData["Title"] Property The ViewData["Title"] property can be set in the controller action method that returns the view. The following code sample shows how to set the ViewData["Title"] property in the CreateStudent action method of the StudentController: ```csharp public IActionResult CreateStudent() { ViewData["Title"] = "Create Student"; return View(); } ``` ### Using the ViewData["Title"] Property in the View The ViewData["Title"] property can be used in the view to set the title of the page. The following code sample shows how to use the ViewData["Title"] property in the CreateStudent.cshtml view: ```html @ViewData["Title"] ``` ### Benefits of Using ViewData["Title"] Using ViewData["Title"] to set the title of the page has several benefits: * It provides a central location to set the page title. * It makes it easy to change the page title from the controller. * It allows the title to be set dynamically based on the data in the model. ### Conclusion ViewData["Title"] is a useful property that can be used to set the title of a page in ASP.NET Core MVC. It is easy to use and provides several benefits.


Comments