Home > MVC > How to call controller method from view on button click



How to call controller method from view on button click

In this article, we will explain how to call controller method from view on button click with an example and sample code.


In this article, we will explain how to call the controller method from view on button click with an example and sample code. In this example, we have created a sample login page, there are two buttons on the login page. based on button click we are redirecting to respective action methods.

 

Step -1

Open Visual Studio. Click on the file in the menu and select new Project .

How to call controller method from view on button click

 

Step -2

Select new project type.

How to call controller method from view on button click

 

Login.cshtml

We have provided razor view html below.

 

Models

 

LoginController

 

Screenshot

How to call controller method from view on button click

 




Note: All contents are copyright of their authors.



Comments



Leave a Reply

Comment:*
Email ID:*


Name:*