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

  • Home
  • SEARCH
  • 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 8223531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:44:11+00:00 2026-06-07T14:44:11+00:00

This is the model example.cs namespace View_Partial_Editor.Models { public class ExampleView { … public

  • 0

This is the model example.cs

namespace View_Partial_Editor.Models
{
    public class ExampleView
    {
            ...
            public string Field1 { get; set; }
            public string Field2 { get; set; }           
            public string Field3 { get; set; }
            public string Field4 { get; set; }
            public string Field5 { get; set; }
            ...

    }
}

I have this view example.cshtml:

@model View_Partial_Editor.Models.ExampleView

@{Html.RenderPartial("EditExample",Model);}    

@Html.TextBoxFor(m => m.Field1)

Then i have this partialView EditExample.cshtml:

@model View_Partial_Editor.Models.ExampleView    

@Html.HiddenFor(m => m.Field1)        

@using (Ajax.BeginForm("EditExample", new AjaxOptions { InsertionMode = InsertionMode.Replace, UpdateTargetId = "partial" }))
{
   <div>
      @Html.EditorFor(m => m, "Editor", null)
   </div>

   <p>
      <input  id="buttona" type="submit" value="Save" /> 
   </p>        
}

I have this controller ExampleController:

namespace View_Partial_Editor.Controllers
{
    public class ExampleController : Controller
    {
        //
        // GET: /Example/    
        public ActionResult Example()
        {
            return View();
        } 

        [HttpPost]
        public ActionResult EditExample(ExampleView example)
        {
            example.Field1 ="7";

            return View("Example", example);
        }    
    }
}

And this is the editor that is called in the partial editor.cshtml

@model View_Partial_Editor.Models.ExampleView

<div class="editor-label">
    @Html.LabelFor(m => m.Field1 )
</div>
<div class="editor-field">
    @Html.EditorFor(m => m.Field1)
    @Html.ValidationMessageFor(m => m.Field1)
</div>
<div class="editor-label">
    @Html.LabelFor(m => m.Field2)
</div>
<div class="editor-field">
    @Html.EditorFor(m => m.Field2)
    @Html.ValidationMessageFor(m => m.Field2)
</div>

My problem is that i want to modify the data of the model in the controller in the ajax call, and return the model modified to the exampleView.But when the ajax called finish the value that i change in the controller is not changed in the model

Edit: The thing that i want is to send the call to the ajax methos, save something in the database, then modify the model, and in the example view i want to have that model with the changes.

In this moment, if i replace the partial view with the result of the ajax, the model in the example view is not modified.Another way is to replace the full example view, so the model is received there, but i have to pass a lot of fields using Html.HiddenFor, is possible to make this without replacing the views only returnng the model with the changes

  • 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-07T14:44:12+00:00Added an answer on June 7, 2026 at 2:44 pm

    Try calling ModelState.Clear() in your HttpPost action method. Html helpers use the values in the ModelState first, then the Model. If you change a value in the model on a post therefore, you need to clear the value from the ModelState.

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

Sidebar

Related Questions

This is just an example, but given the following model: class Foo(models.model): bar =
Why don't DataAnnotations work on public fields? Example: namespace Models { public class Product
the best way to explain is with example so: this is the model public
Assume I have this model : class Task(models.Model): title = models.CharField() Now I would
I have this model in django: class JournalsGeneral(models.Model): jid = models.AutoField(primary_key=True) code = models.CharField(Code,
Let's consider this model class Session(models.Model): tutor = models.ForeignKey(User) start_time = models.DateTimeField() end_time =
I defined a model like this public class Planilla { [Key] public int IDPlanilla
I can read settings like this, for example: final String mytest = System.getString(this.getContentResolver(), System.AIRPLANE_MODE_ON);
Trying to get my head around backbone.js. This example is using Backbone Boilerplate and
In the following console application example, the event is defined like this: public delegate

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.