ASP.net MVC 2 SPARK - Create "Add New Item" link in spark page.

Posted by KarlBear on Stack Overflow See other posts from Stack Overflow or by KarlBear
Published on 2010-12-08T23:50:11Z Indexed on 2011/01/03 16:53 UTC
Read the original article Hit count: 283

I have a web form in SPARK which allow the editing of a Facility class that contains Rooms. When editing the Facility all the Rooms are listed for editing too. The form works fine for editing, but I would like to include a button "Add Room" that adds a new blank room below the existing ones. Any idea how this is accomplished?

Currently I am doing this in my SPARK page:

[All the Facility editing stuff...]
<p>Room</p>
 <div class="small">Enter the rooms associated with this facility.</div>
  <div class="add">
    <div id="room">
      <AddFacilityRoom each="var roomModel in Model.FacilityRooms" RoomModel="roomModel" Index="roomModelIndex" />
    </div>
    <a id="addRoom" class="add" href="events/room/add.mvc">Add a room</a>
  </div>

AddFacilityRoom contains the html elements for editing a room.

I would like add.mvc to create a new empty Room class and inject a new identical (but empty) control below the existing ones. Currently, though it opens a new page when the "Add a Room" button is clicked.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about asp.net-mvc-2