vendredi 30 juillet 2021

Show Partial View Based on Ajax Link

I am trying to show two partial views in the same div based on two ajax action links. If a user clicks "Process'", then the div renders the process_partial_view. If the user clicks "Logs", the the div renders the log_partial view.

I cannot seem to differentiate the ajax link that is click and show the appropriate view in an if statement. I have also tried using variables in tempdata. Any help would be greatly appreciated.

        <td>
                            @Html.ActionLink(linkText: "Edit", actionName: "Edit_Application", controllerName: "GenericBO", routeValues: new { id = item.App_ID }, htmlAttributes: null)
                            |
                            @Ajax.ActionLink("Process'", "Show_Process_Main_View", new { id = item.App_ID }, new AjaxOptions { UpdateTargetId = "result" }, TempData["view_partial"] = "Process")
                            |
                            @Ajax.ActionLink("Logs", "Show_Logs_Main_View", new { id = item.App_ID }, new AjaxOptions { UpdateTargetId = "result" },TempData["view_partial"] = "Log")

                        </td>

      <div class="col-lg-7 ">

    <div id="result" style=" margin: 3.5%; width:auto;">
        <h1>@TempData["view_partial"].ToString()</h1>
        <p></p>
        @if (TempData["view_partial"].ToString() == "Log")
        {
       
            { Html.Partial("Show_Logs_Main_View"); }
        }
        else if (TempData["view_partial"].ToString() == "Process")
        {
            { Html.Partial("Show_Process_Main_View"); }
        }
        <h1>@TempData["view_partial"].ToString()</h1>

    </div>

</div 

Aucun commentaire:

Enregistrer un commentaire