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 4611322
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:15:08+00:00 2026-05-22T01:15:08+00:00

I have a simple mvc project consisting of one table named Persons and that

  • 0

I have a simple mvc project consisting of one table named Persons and that table has some attributes like name, age, surname and so on.

I Recently added an attribute to table which is type of bit in SQL and bool in C# and for me it represents some status. If it is ok I put that status to true or false.

In one controller I create an index view of my Persons in the database and I display the status as a checkbox. That is working ok. What I want to do is to change the status if I click on that checkbox instead of using an edit view for all of the atributes.
I just want to save checkbox value from my index view to database.

Some people advised me to create an action in my controller like so:

public ActionResult Save(int id, bool status){}

Where id is id of my person in db and status is a value of the checkbox I clicked.

So how do I call that function with jquery, ajax or javascript and send those params?
I am not so good with ajax and a little bit afraid of it 🙂

And one more thing I manage to show checkbox value corectly from my databse only in this way:

@Html.CheckBox("somename", item.Status)
        <input name="somename" type="hidden" value="false"/>

Any help or advice or sending me to good direction is good!

  • 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-05-22T01:15:09+00:00Added an answer on May 22, 2026 at 1:15 am

    You have several options. One way would be to place the checkboxes in a (normal) form and then use the jQuery Form plugin to Ajaxify the form:

    @using(Html.BeginForm()) {
        @Html.Checkbox(...)
    }
    
    <script type="text/javascript">
        $(document).ready(function () {
            $('form').ajaxForm({
                success: Saved,
                error: HandleError
            });
        });
    
        function Error(response, status, err) {
            // code to handle error here
        }
    
        function Saved(responseText, statusText, xhr, $form) {
            // code to handle succes, if any
        }
    </script>
    

    You could, of course, use an @Ajax.BeginForm as well, but this has the advantage of being easily downgradable. Just remove the jQuery form initialisation and you got yourself a regular form : )

    Another possibility is to simply use an @Ajax.ActionLink. I wrote a blog post on how to deal with Ajax.ActionLink that I think will help you out.

    The signature for your controller action on your question looks correct:

    public ActionResult Save(int id, bool status){}
    

    Another options is actually to create a Settings view model (call it what you will), and in there just have a bunch of bool properties to represent the checkboxes:

    public class Settings
    {
        public bool Status { get; set; }
        // more properties here
    }
    

    then you can bind your action to the Settings object:

    public ActionResult Save(int id, Settings settings){}
    

    This will come in handy in case you end up having multiple checkboxes to bind.

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

Sidebar

Related Questions

I am working on a MVC project that is supposed to have one page
I'll keep it simple. I have an ASP MVC project. It has all the
I have a simple MVC 4 (Beta) Application and just observed something that I
Have a simple Spring MVC portlet, and from one of portal pages I have
I have a very simple MVC site that is returning a 404 not found
I have a relatively simple ASP.net MVC 2 app that is using SubSonic. Everything
I have created simple HelloWorld project from Spring MVC template in Spring STS. I
In my mvc project i have a simple list of items with crud operations
I have a simple ajax method in my MVC.Net project which adds entries to
I have created a simple MVC application that is using the .Net Membership Provider

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.