Header add

 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.





When you type something and press on the hit button, it can popup like javascript messagebox.







Post a Comment

Previous Post Next Post