In this article we will discuss about Display Message from Controller in View using JavaScript Alert MessageBox in ASP.Net Core MVC.
The message sent from Controller to View will be displayed in JavaScript Alert MessageBox using ViewBag object in ASP.Net MVC Core.
Before start this article, please visit our previous article Hello World Tutorial with Sample Program
View
The View consists of an HTML Form which has been created using the Html.BeginForm method with the following parameters.
- ActionName – Name of the Action. In this case the name is Index.
- ControllerName – Name of the Controller. In this case the name is Home.
- FormMethod – It specifies the Form Method i.e. GET or POST. In this case it will be set to POST.
Controller
The Controller consists of two Action methods.
- GET & POST
GET :This action is used for handling GET operation. Inside this Action method, simply the View is returned.
POST : This action is used for handling POST operation. This Action method handles the Form submission and it accepts the value of the Form element as parameter.
The name of the parameter must be same as the value of name attribute specified for the Form element.
You May Also Like...
- Send email with attachment in .NET Core
- Difference between AddSingleton vs AddScoped vs AddTransient
- Dependency Injection in Asp.Net Core
- How to read values from appsettings.json in Asp.Net Core
- How to Get Application Base Path in Asp.Net Core
- Import and Export Excel file in ASP .NET Core 3.1 razor page
- Consume Restful API to get the bank details using IFSC Code in .NET Core
- Create ASP .NET Core MVC application using VS Code
- Generate QR Code in .NET Core using Bitmap
- How to Securely Open PDF in Browser using .NET Core
Post a Comment