Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9041491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:15:08+00:00 2026-06-16T10:15:08+00:00

I know this is a pretty basic question over here. But could you tell

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T10:15:09+00:00Added an answer on June 16, 2026 at 10:15 am

    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

    [HttpGet]
    public ActionResult Foo(string id)
    {
        var person = Something.GetPersonByID(id);
        return Json(person, JsonRequestBehavior.AllowGet);
    }
    

    Jquery GET

    function getPerson(id) {
        $.ajax({
            url: '@Url.Action("Foo", "SomeController")',
            type: 'GET',
            dataType: 'json',
            // we set cache: false because GET requests are often cached by browsers
            // IE is particularly aggressive in that respect
            cache: false,
            data: { id: id },
            success: function(person) {
                $('#FirstName').val(person.FirstName);
                $('#LastName').val(person.LastName);
            }
        });
    }
    

    Person class

    public class Person
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }
    }
    

    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 as post 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

    @using (Html.BeginForm("SaveData","ControllerName", FormMethod.Post))
    {        
        @Html.TextBoxFor(model => m.Text)
        
        <input type="submit" value="Save" />
    }
    

    Action Method

    [HttpPost]
    public ActionResult SaveData(FormCollection form)
        {
            // Get movie to update
            return View();
       }
    

    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 and FormMethod.Get for View’s form method.

    I hope this will help to you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good day, all. I know that this is a pretty basic question in terms
I know this is a basic RTFM question but I'm pretty new to rails
This seems like a pretty basic question but I unfortunately don't know the answer
I know this is a pretty basic question, but I don't know how to
I'm pretty sure that this is a basic question but I really don't know
I know this is a pretty basic regex, could someone explain what it is
I think my question is pretty basic, but I'm writing this code in OpenCV
I'm afraid this question is pretty basic, but I think it's relevant to a
This is probably a pretty basic question, but just something that I wanted to
This might be a pretty basic question, but how do you add new users

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.