maztt
maztt

Reputation: 12304

asp.net mvc calling different usercontrol from different view

I Have a View Folder

FrontEnd
JobDetails.ascx (View)

Another View Folder Job Apply.ascx (view)

I have a Apply (a href) in jobdetails which have a show and hide div mechanism for apply (Rendering Apply.ascx in JobDetails

 <div id="div1" style="visibility:hidden">
        <% Html.RenderPartial("../../Views/Jobs/Create"); %>
    </div>

my create View in job

    <% using (Html.BeginForm("Create", "Jobs", FormMethod.Post, new { enctype = "multipart/form-data" }))
   {%>
    <%: Html.ValidationSummary(true) %>
    <table border="0" cellpadding="0" cellspacing="0"> 
      <tr>
        <td></td>
      </tr>
      <tr>
        <td>

<% } %>

the question is that how would i go back in the JobDetails View if some Error occurs in my create form to display the errors there . I am at lost here , hope that the question is clear enough.

Upvotes: 0

Views: 210

Answers (1)

tvanfosson
tvanfosson

Reputation: 532745

Probably the simplest way to handle this is to do the post of the apply via AJAX and simply render the apply form with the errors in place by replacing the existing HTML with that returned when the apply fails. If javascript is turned off, then it will render just the failed application but that seems like a reasonable trade-off to me.

Upvotes: 1

Related Questions