I know this is a pretty basic question over here.
But could you tell me all possible options available to,
call a Control Action Method [generally any server side routine] from a Razor View and,
in what scenarios each are best applicable to be used in.
Thanks.
Method 1 : Using jQuery Ajax Get call (partial page update).
Suitable for when you need to retrieve jSon data from database.
Controller's Action Method
Jquery GET
Person class
Method 2 : Using jQuery Ajax Post call (partial page update).
Suitable for when you need to do partial page post data into database.
Post method is also same like above just replace
[HttpPost]
on Action method and type aspost
for jquery method.For more information check Posting JSON Data to MVC Controllers Here
Method 3 : As a Form post scenario (full page update).
Suitable for when you need to save or update data into database.
View
Action Method
Method 4 : As a Form Get scenario (full page update).
Suitable for when you need to Get data from database
Get method also same like above just replace
[HttpGet]
on Action method andFormMethod.Get
for View's form method.I hope this will help to you.