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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:29:52+00:00 2026-05-23T03:29:52+00:00

I have a classes like this: public class member { public string name {get;set;}

  • 0

I have a classes like this:

public class member
{
 public string name {get;set;}
 public IList<Note> notes {get;set;}
}

public class note
{
 public string text {get;set;}
 public datetime created {get;set;}
}

I want to have a page which inserts the member class – which i am fine with. My question lies in how to go about adding multiple notes to the member on the same page?

What would be the best way to go about this? (maybe some ajax solution to show sub forms for the note class)

Can anyone point me in the right direction of some related examples learning material?

Thanks in advance.

  • 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-23T03:29:53+00:00Added an answer on May 23, 2026 at 3:29 am

    I’d create an Ajax form that posts to a method called AddNote(AddNoteViewModel viewModel) on your controller. AddNoteViewModel would contain all the information you need to create a new note. The AddNote Action Method would add the new note, SaveChanges and return a list of notes for the given Member. You can use a partial view for the content that is returned from AddNote.

    On the Ajax form you should set UpdateTargetId to the id of the <div> you want to update with the latest list of notes.

    Another option might be to use JQuery.

    Here is a good example of both: Using Ajax.BeginForm with ASP.NET MVC 3 Razor

    UPDATE : I’ve adapted Darin Dimitrov’s example (from the link) to suit your scenario. This is off the top of my head so won’t be perfect but it should give you a decent starting point

    Model:

    public class AddNoteViewModel
    {
        [Required]
        public int MemberId { get; set; }
        [Required]
        public string Text { get; set; }
    }
    

    Controller:

        [HttpPost]
        public ActionResult AddNote(AddNoteViewModel model)
        {
            var member = //Get member from db using model.MemberId
            member.Notes.Add(new Note{Text = model.Text, Created = DateTime.Now});
            //SaveChanges();
    
            var notes = //Get notes for member
    
            return View(notes);
        }
    

    View:

    @model AppName.Models.AddNoteViewModel
    
    <script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")" type="text/javascript"></script>
    
    <div id="result"></div>
    
    @using (Ajax.BeginForm(new AjaxOptions { UpdateTargetId = "result" }))
    {
        @Html.HiddenFor(x => x.MemberId)
        @Html.EditorFor(x => x.Text)
        @Html.ValidationMessageFor(x => x.Text)
        <input type="submit" value="OK" />
    }
    

    Using JQuery:

    View:

    @model AppName.Models.AddNoteViewModel
    
    <script src="@Url.Content("~/Scripts/jquery.validate.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/index.js")" type="text/javascript"></script>
    
    <div id="result"></div>
    
    @using (Html.BeginForm())
    {
        @Html.HiddenFor(x => x.MemberId)
        @Html.EditorFor(x => x.Text)
        @Html.ValidationMessageFor(x => x.Text)
        <input type="submit" value="OK" />
    }
    

    index.js:

    $(function () {
        $('form').submit(function () {
            if ($(this).valid()) {
                $.ajax({
                    url: this.action,
                    type: this.method,
                    success: function (result) {
                        $('#result').html(result);
                    }
                });
            }
            return false;
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have classes like this public class someList { public string strOne {get; set;}
Basically I have 2 classes, Manifest and BrowserAction, set out like this: public class
I have some classes layed out like this class A { public virtual void
I have Java classes like this: public class Config { public Config1 getConfigOpt1(); public
Let's say I have two classes that look like this: public class ByteFilter {
I have an hierarchical structure of classes like this public class Class1 { internal
I have two classes declared like this: class Object1 { protected ulong guid; protected
I have two classes, Foo and Bar, that have constructors like this: class Foo
I have a class which I can write like this: class FileNameLoader { public:
I have a class MyClass and an inner class MyNestedClass like this: public class

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.