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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:47:04+00:00 2026-06-01T21:47:04+00:00

I’m trying to learn ASP.NET MVC 3 coming from a web forms background. I’m

  • 0

I’m trying to learn ASP.NET MVC 3 coming from a web forms background. I’m trying to work out what would be the MVC way of implementing what I want, and the actual difficultly is that I am not sure what to google!

What I can’t get my head around is how to work with more complex models. All the tutorials on the asp.net site work around fairly simple data objects, and consequently rather simple editors to manage the data with them.

Imagine a model for a hypothetical Party booking application:-

public class Party
{
    public string PartyName {get;set;}
    public DateTime PartyDate {get; set; }

    public ICollection<Guest> Guests {get; set;}
}

public class Guest
{
    public string Name {get; set;}
    public string EmailAddress {get; set;}
}

The key here is the collection of guests.

What I want to understand how to achieve, is how to implement a controller+view which would allow me to create a Party and also add new Guests at the same time, in a single page (and preferably with the guest add/remove functionality in-page in ajax).

In a similar app in asp.net web forms, it would be straight forward to put the functionality for the guests in an UpdatePanel. But I am not sure how to go about implementing this in MVC.

If anyone has any tips, pointers, or links to articles that discuss similar topics, i’d be very greatful,

Thanks

slip

  • 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-01T21:47:05+00:00Added an answer on June 1, 2026 at 9:47 pm

    Use jQuery ajax to handle adding many guests.

    1) With a Model Popup When you click on the Add Guest button, Call your Action method which returns the Guest for m in a model dialog ( jQuery UI dialog is one option to use here). Save the data using an ajax post call. One the success event, append the new guest data to the main forms list of guests or reload that part only using jquery load

    2) Inpage Adding When you click on the Add Guest button, In the main form itself, Show the form ( you can dynamically create input box and save button from javascript in a variety of ways). save the data using a jQuery ajax post. Send the data as a json.As long as the parameter names matches with the property name of your ViewModel, your action method can accept the data

    Your HTML page

    <a href="#" id="addNew"> Add Guest</a>
    
    <div id="divForm" style="display:none">
        <input type="text" id="txtName" />
        <input type="text" id="txtEmail" />
        <input type="button" id="btnSaveGuest" value="Save"/>
    </div>
    <ul>
    
    <div id="divGuests"></div>  
    

    In your script

    $(function(){
      //Show the hidden form
      $("#addNew").click(function(){
          $("#divForm").fadeIn(300);
      }); 
    
       //Save the new guest details
       $("#btnSaveGuest").click(function() {
         var name=$("#txtName").val();
         var email=$("#txtEmail").val();
         $.ajax({
            url: '@Url.Action("SaveGuest","Guest")',
            data: {Name: name, EmailAddress :email},
           success: function(data) {
    
            if(data=="true")
            {
              //Saved successfully.May be append to list of Guest
              $("#divGuests").append("<p>"+name+"</p>");
            }
            else
            {
              //Error. Show msg to user
            }
           }
         });
       });
    });
    

    Your Action method to save

    [HttpPost]
    public ActionResult SaveGuest(Guest objGuest)
    {
      try
      {
      // read the objGuest property values and Save to db
    
       return "true";
      }
      catch(Exception e)
      {
         //Log error
         return "false";
      }
    }
    

    Here is a sample app : http://jsfiddle.net/Qzk3F/16/
    (some values are hardcoded in the example)

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:

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.