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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:14:12+00:00 2026-05-18T20:14:12+00:00

I have a list of Child objects. I would like to be able to

  • 0

I have a list of Child objects. I would like to be able to toggle whether they are included in a smaller list of objects which have a relationship to a Parent object. Like so:

<% foreach(var child in Model.AllPossibleChildren)%>
<% { %>
<tr>
    <td>
        <%if(child.Link.Any(r => r.Id == Model.Parent.Id))
            { %>
            <%:Ajax.ActionLink("Remove", "RemoveChild", new { aId = Model.Parent.Id, rId = child.Id }, null)%>
        <% } 
            else 
        { %>
            <%:Ajax.ActionLink("Add", "AddChild", new { aId = Model.Parent.Id, rId = child.Id }, null)%>
        <% } %>
    </td>
</tr>
<% } %>

The idea here is that when the user clicks on “Remove”, it will remove the relationship between the Parent and Child, and then somehow (using Jquery or AjaxOptions) toggle the ActionLink parameters to match the other condition (Add instead of Remove for link text, AddChild instead of RemoveChild for action method). That’s the part I’m unclear on.

  1. Am I approaching this correctly, or is there a better way to do this?
  2. If this is the right approach, which would be better to use – AjaxOptions or JQuery (I’m guessing the answer is JQuery, since it’s more flexible)
  3. Depending on the answer to #2, how would I do that?

Incidentally, here’s my action method. I tested that they are called correctly and pass the correct parameters.

    public JsonResult AddChild(string aId, int rId)
    {
        //Create Relationship
        return Json(result);
    }

    public JsonResult RemoveChild(string aID, int rID)
    {
        //Remove Relationship
        return Json(result);
    }

Thanks!

UPDATE
I’ve investigating using partialviews for this, but can’t seem to get that to work either. I keep coming back to this model, and continue to not be able to figure out how to get it to work! I don’t want to have to repost the whole page, although with the way I have it set up right now it would work. Perhaps that’s my problem? Still looking for some help!

  • 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-18T20:14:13+00:00Added an answer on May 18, 2026 at 8:14 pm

    I gave up on using Ajax.ActionLink and went with a straight div/ jquery ajax approach. Not that I knew how to do that either…see my subsequent question and my final working answer here: Can't get jquery $ajax to call .NET MVC 2 controller method

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

Sidebar

Related Questions

I have a list of Child objects. I would like to be able to
I have a list of parent/child IDs and would like to get all child
I would like to create list of child objects from list of parent object.
I have an unordered list that is a child in a smaller parent div
I have an abstract class which I would like to be able to expose
I have one-to-many relationship between parent and child Java objects. The parent object uses
I have two Entity Framework objects with a one-to-many relationship: widget(parent) and widgetNail(child) Widget
I have an std::list<TYPE> which may contain child classes of TYPE. I need to
I have a class that has an internal list of other objects like so:
i would like to have bidirectional navigation methods in classes between child object and

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.