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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:55:18+00:00 2026-05-30T14:55:18+00:00

How can I add a new object item to a Main Views model that

  • 0

How can I add a new object item to a Main Views model that has been created in a different model?

I am trying to add a new item to a list which is contained in my main view model.

Before adding this item, I need info about the properties for this item, so I use a view strongly tied to a model which contains necessary input fields. I have made the model for this view a wrapper style which contains two objects. The main view’s model as well as a model for the specific item.

MODEL

public class MDTCompletedJobM : BaseM
{
...
public MDTPartMList PartsList { get; set; }
...
}


public class MDTAddPartM
{
    public MDTPartM Part { get; set; }
    public MDTCompletedJobM CompletedJobM { get; set; }
    public List<string> PartTypes { get; set; }

    public MDTAddPartM()
    {
        Part = new MDTPartM();
        PartTypes = (List<string>)ConfigurationManager.GetSection("MTDataPartTypeList");
    }
}

so when the view is called from my controller, I assign my mains views model to this model and pass it in. From the “Add Part” view, I then use an Ajax post call to actually add the part to this List (CompletedJobM.PartsList).

This works fine except I now don’t know how to get my main view to be aware in it’s model that there is an extra Item in it’s list. This new item is not “stored” anywhere after it’s been added to the model list, so I can’t reload the main view model. My Ajax post is:

 $.ajax({
            type: "POST",
            cache: false,
            url: '@Url.Action("AddPart", "Jobs")', //$(this).attr("action"),
            data: $.toJSON(result),
            contentType: 'application/json',
            success: function (data) {

                $("#progressdiv").html();

                var isValid = $(data).find(".validation-summary-errors").length == 0;

                if (isValid) {
                    var pwindow = $("#Window").data("tWindow");
                    pwindow.close();
                    $('.page').html(data); <- what to do here?
                }
                else {

                    $("#resultDiv").html(data);
                }
            },

            beforeSend: function () {
                $("#progressdiv").html('<image src=@Url.Content("~/Content/Images/ajax-loader.gif") alt="Loading, please wait" />');
            },

            error: function (xhtr, e) {
                $("#progressdiv").html();
                alert(xhtr.responseText);
            }
        });

Currently (since I’m returning a View) I tried just assigning the returned HTML to a tag of the main view, but that caused issues with overlapping displays and further processing issues with button clicks and so forth.

My question is at the top line? Maybe I’ve gone about it all wrong?

Thanks

EDIT

Ok, let me rephrase this question slightly. Ignore my actual code. What principles or general concept would someone use to update a model of one View (in this case a list) with the model from a different view (entry form), such that when refreshing the Main View it contains the information from the 2nd view bearing in mind that after the second view has been updated/posted, it’s not written to a DB or anywhere. It’s effectively in memory.

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-05-30T14:55:19+00:00Added an answer on May 30, 2026 at 2:55 pm

    What I ended up doing was storing my Model in the Session object and retrieved it and used that while re-rendering the page.

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

Sidebar

Related Questions

I know that i can enter/add new properties via code manually into partial classes
I've got a web page where the user can add a new item to
I have the problem: I can not add new item to the same combobox
Can I add new Silverlight 2.0 projects to my ASP.NET 2.0 web app and
How can I, in Java or using some other programming language, add a new
I am new to wxPython. Can someone help me in: How to add multiple
I know that I can add a HintPath to an external DLLs to help
I am creating a survey page that has a list of questions and answers
I would like to create a interface that I can use with different types.
I'm trying to have a View where the user can add items in a

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.