views:

29

answers:

0

Hello Everyone, i m working on a meeting manager and on configure meeting page i call three renderActions to populate the page.

<fieldset>
        <span style="float:right;margin-right:20px;color:Red;"><%=TempData["error"] %></span>
       <%Html.RenderAction("MeetingInfo", new { meetingid = Request["meetingid"] }); %><br />            
       <div id="tbldata">
            <%Html.RenderAction("Attendance", new { meetingid = Request["meetingid"] }); %>
       </div>
       <br />
    <% } %>

       <%Html.RenderAction("AgendaWithMinutes", new { meetingid = Request["meetingid"] }); %>
    </fieldset>  

third renderAction ("AgendaWithMinutes") renders the agenda items and minutes associated with each agenda item. it also renders form with each agenda item to add minute information asynchronously.Below is ControllerAction for AgendaWithMinutes

public ActionResult AgendaWithMinutes(int meetingid) 
        {
            return PartialView(new VMAgenda(meetingid, false, EmployeeID));
        }

VMAgenda is my viewModel that contains all information about agenda and associated minutes. below is the code of partial view ("AgendawithMinutes.Ascx")

<%foreach(var agenda in Model.Agenda){ %>
  <div class="tblrow" >   
   <div class="tblcelltxt" style="color:Teal;">
    <h3><a href="#" class="shownext"><%=agenda.AgendaText %></a></h3>
   </div> 
  </div>

    <div class="tblrow" id="description" style="display:none;">  
        <div class="tblcelltxt" style="color:#888888;" >
        <%=agenda.Description %>
       </div>      
   </div>  
   <div class="tblrow" >   
   <div class="tblcelltxt" >
       <div class="form_here"></div>
        <%Html.RenderPartial("AgendaLinks", agenda); %>    
       </div>   
  </div>   

<%} %>

here you can see i m calling another partial view that will render the form and associated links. below is code of Agendalinks.ascx

<div  id="minute_form_div-<%=Model.MeetingAgendaID%>" style="display:none;vertical-align:middle;" class="minutform" >
    <%Html.EnableClientValidation(); %>
        <%using (Ajax.BeginForm("Minutes", null, new AjaxOptions {OnSuccess = "MinutesProcessed", UpdateTargetId = "minutes_div-"+Model.MeetingAgendaID}, new { id = "form-" + Model.MeetingAgendaID }))
          { %>
            <%=Html.Hidden("oaMinute.MeetingAgendaID", Model.MeetingAgendaID)%>
            <%=Html.TextArea("oaMinute.Minute")%>
            <%=Html.ValidationMessage("oaMinute.Minute") %>
            <%=Html.Hidden("oaMinute.EmployeeID", Model.EmployeeID)%>
            <%=Html.Hidden("oaMinute.MinuteID",0)%>

            <button type="submit" class="button">Save</button>
        <%} %>

    </div>
    <div id="minutes_div-<%=Model.MeetingAgendaID%>" class="minutelist"><%Html.RenderAction("MinuteList", new { id = Model.MeetingAgendaID }); %> </div>
    <a href="#<%=Model.MeetingAgendaID%>" class="add_minute">Add Minute</a>&nbsp;|&nbsp;
    <%=Ajax.ActionLink("Add/Edit Conclusion", "EditAgenda", new { id = Model.MeetingAgendaID }, new AjaxOptions {})%>&nbsp;|&nbsp;

main problem here is that when i submit form using ajax validation does not work. reason is because i return updated minutes in case form is persisted successfully. if form is invalid how can i return Error messages to the form. i can only give one value in UpdateTargetID and in my case it is the ID of div containing minutes. is there a way or workaround to this problem