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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:10:57+00:00 2026-06-13T15:10:57+00:00

can’t find whats wrong and can’t find answer anywhere. My problem is my view

  • 0

can’t find whats wrong and can’t find answer anywhere. My problem is my view not updated after view model have bean changed

ViewModel:

public class OrderView
{
    public Customer Customer { get; set; }
    public Order Order { get; set; }
}
public class Order
{
    public int OrderId { get; set; }
    public int CustomerId { get; set; }
    public List<string> DomenNames { get; set; }
}
public class Customer
{
    public int Id { get; set; }
    public string Name { get; set; }
    public string Telephone { get; set; }
    public string Email { get; set; }
}

Controller:

private OrderView ov;
public ActionResult Index()
{
    return View(ov);
}

[HttpPost]
public ActionResult Index(OrderView model, FormCollection collection) {            
    return View("done");
}
public ActionResult BlankEditorRow(OrderView model) {
    ov = model;
    ov.Order.DomenNames.Add("");
    return View("Index",ov) ;
}

View:

@using (Html.BeginForm("Index","Order",FormMethod.Post, new {id = "createOrder"})) {
@Html.ValidationSummary(true)
<fieldset>
    <legend>Order</legend>

    <div class="editor-label">
        @Html.LabelFor(model => model.Order.DomenNames)
    </div>

    @for(int i = 0; i < Model.Order.DomenNames.Count; i++) {
        <div> 
            @Html.EditorFor(item => item.Order.DomenNames[i])
        </div>
    }

    <button type="button" id="b1" onclick="setallert()" >Click me</button>
 ...

and script:

<script type="text/javascript">
    function setallert() {
        $.ajax({
            url: "Order/BlankEditorRow",
            data: $('#createOrder').serialize(),
            cache: false,
            success: function (data) {
                ...?
            }
        });
    };    
</script>

it goes fine to pass model to controller and while debugging through view I can see that model is changed, but in some case it nothing happen in view. It looks like old model is in place.

  • 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-13T15:10:59+00:00Added an answer on June 13, 2026 at 3:10 pm

    I have solved my problem. I post my solution in case some one need it:

    Controller:

    public ActionResult BlankEditorRow(OrderView model) {
        model.Order.DomenNames.Add("");
        return PartialView("Index", model) ;
    }
    

    View:

    <div class="editor-label">
        @Html.LabelFor(model => model.Order.DomenNames)
    </div>
    <div id="tt">
        @{Html.RenderPartial("OrderDN", this.Model);}
    </div>
    <button type="button" id="addBtn">Click me</button>
    

    Script:

    $("#addBtn").click(function () {
        $.get('@Url.Action("BlankEditorRow", "Order")', $('#createOrder').serialize(), function (res) {
            document.getElementById("tt").innerHTML = res;
        });
    })
    

    I hope it will be useful to someone

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

Sidebar

Related Questions

Can anyone help me as what is going wrong here? Am not able to
Can not find scala.actors package in latest milestones, while it still presents in scaladocs:
Can I order my users in the database, so I don't have to say
I have a jquery bug and I've been looking for hours now, I can't
Can't find information about JavaScript usage with Compass, in configuration i found an javascript_dir
Can't figure out how to do this in a pretty way : I have
Can't seem to figure out what's wrong with the simple getJSON call below. It's
Can anyone (maybe an XSL-fan?) help me find any advantages with handling presentation of
Can find why i get this error can someone help? package Android.data; public class
Can you have submenus with the top level set to checkable in WPF? I

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.