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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:55:34+00:00 2026-05-14T02:55:34+00:00

Ok, everything is ‘functionally’ working with what I am attempting to accomplish and once

  • 0

Ok, everything is ‘functionally’ working with what I am attempting to accomplish and once again, I am sure this is something dumb, but I cannot figure out how to do this one thing.

I have an edit form for an entity, lets say a car. This ‘car’ can have 0 – many passengers. So on my edit form, I have all the fields for the car, then a list view showing each passenger (partial). I also have a ‘add new passenger’ button that will render a new partial view that allows you to enter a passenger. This has a cancel link and an add button to submit an Ajax form. When you add a passenger, the passenger is automatically added to the list, but I need the enter passenger form to go away. I have tried using the onSuccess and onComplete functions to hide the div that the form is in, but both render just the partial view HTML elements (white screen, text) and not the partialView in the context of the entire page.

Sources:
1) Main Edit View

    <script type="text/javascript">
    Function hideForm(){
        document.getElementById('newPassenger').style.display = 'none';
    }

</script>
<h2>Edit</h2>

<%-- The following line works around an ASP.NET compiler warning --%>
<%= ""%>

<%Html.RenderPartial("EditCar", Model)%>
<h2>Passengers for this car</h2>
<%=Ajax.ActionLink("Add New Passenger", "AddPassenger", New With {.ID = Model.carID}, New AjaxOptions With {.UpdateTargetId = "newPassenger", .InsertionMode = InsertionMode.Replace})%>
<div id="newPassenger"></div>
<div id="passengerList">
    <%Html.RenderPartial("passengerList", Model.Passengers)%>
</div>
<div>
    <%= Html.ActionLink("Back to List", "Index") %>
</div>

2) AddPassenger View. The cancel link below is an action that returns nothing, thus removing the information in the div.

<%  Using Ajax.BeginForm("AddPassengerToCar", New With {.id = ViewData("carID")}, New AjaxOptions With {.OnSuccess = "hideForm()", .UpdateTargetId = "passengerList", .InsertionMode = InsertionMode.Replace})%>   
    <%=Html.DropDownList("Passengers")%> 
    <input type="submit" value="Add" />
    <%=Ajax.ActionLink("Cancel", "CancelAddControl", _
                                            New AjaxOptions With {.UpdateTargetId = "newPassenger", .InsertionMode = InsertionMode.Replace})%><% end using %>
  • 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-14T02:55:34+00:00Added an answer on May 14, 2026 at 2:55 am

    Ok – figured this out, I suppose it was getting too late last night. So, here is the answer, it actually turned out to be a few small issues culminating into one.

    1. Function hideForm() in the javascript should be function hideForm(), no capitals. Too used to writing controller functions I suppose.
    2. I was using “hideForm()” in the OnSuccess attribute, not “hideForm” – doh.
    3. You probably don’t want to hide the div as when you click the add new passenger link again, the div won’t display. Changed hideForm function to set the innerHTML property of the div to ”.

    Thanks again darin for your assistance, I was trying to making more out of it than it turned out to be.

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

Sidebar

Related Questions

Everything inherits from object. It's the basis of inheritance. Everything can be implicitly cast
Everything I have read says that when making a managed stored procedure, to right
Everything I read about better PHP coding practices keeps saying don't use require_once because
Everything I can find in linq for aggregation has a group by clause. How
Everything is an object was one of the first things I learned about Ruby,
Everything was going well. Nightly builds ran for more than a month with no
Everything works fine when the unit tests class is part of the main project
Store everything in GMT? Store everything the way it was entered with an embedded
From everything I've read, it seemed that adding paging to a ListView control should
Table1: Everything including the kitchen sink. Dates in the wrong format (year last 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.