locked
MVC, Partial view with details. I want to hide (Details) text at the below of grid. RRS feed

  • Question

  • User-240513752 posted

    I have an MVC project, simple is that i am using a partial view (_DetailOnParentPage.cshtml) in a partial view (Index.cshtml).

    why this text (Details) appearing in the below of grid? I want to hide it. Please check the video for better understanding.

    Video Link

    Tuesday, April 21, 2020 7:27 AM

Answers

  • User-17257777 posted

    Hi Khan_1,

    Khan_1

    @Ajax.ActionLink("Details", "_DetailOnParentPage", new AjaxOptions { })

    Because you have defined a Ajax.ActionLink at the end. You can just remove it.

    Best Regards,

    Jiadong Meng

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 23, 2020 2:44 AM

All replies

  • User-17257777 posted

    Hi Khan_1,

    The link seems to be unavailable, maybe you can post your codes which has problem here.

    Best Regards,

    Jiadong Meng

    Tuesday, April 21, 2020 9:32 AM
  • User-240513752 posted

    jiadongm

    Hi Khan_1,

    The link seems to be unavailable, maybe you can post your codes which has problem here.

    Best Regards,

    Jiadong Meng

    Index.cshtml 

    @model IEnumerable<netEF_with_Code_First_approach.Models.StudentModel>
    
    @{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
    }
    <script src="~/Scripts/jquery-3.3.1.js"></script>
    <script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script>
    
    
    <p>
    @Html.ActionLink("Create New", "Create")
    </p>
    <table class="table">
    <tr>
    <th>
    @Html.DisplayNameFor(model => model.StudentName)
    </th>
    <th>
    @Html.DisplayNameFor(model => model.StudentAddress)
    </th>
    <th>
    @Html.DisplayNameFor(model => model.StudentMobile)
    </th>
    <th></th>
    </tr>
    
    @foreach (var item in Model)
    {
    <tr>
    <td>
    @Html.DisplayFor(modelItem => item.StudentName)
    </td>
    <td>
    @Html.DisplayFor(modelItem => item.StudentAddress)
    </td>
    <td>
    @Html.DisplayFor(modelItem => item.StudentMobile)
    </td>
    <td>
    @Html.ActionLink("Edit", "Edit", new { id = item.StudentId }) |
    @Ajax.ActionLink("Details", "_DetailOnParentPage", "Student", new { id = item.StudentId },
    new AjaxOptions { UpdateTargetId = "AcademicDetails" })
    
    |
    @Html.ActionLink("Delete", "Delete", new { id = item.StudentId })
    
    </td>
    </tr>
    }
    
    </table>
    
    <div id="AcademicDetails">
    @Ajax.ActionLink("Details", "_DetailOnParentPage", new AjaxOptions { })
    
    </div>
    
    

    Partial View which is in Index.cshtml

    @model netEF_with_Code_First_approach.Models.StudentModel
    
    <div>
        <h4>Student Details</h4>
        <hr />
        <dl class="dl-horizontal">
            <dt>
                @Html.DisplayNameFor(model => model.StudentName)
            </dt>
    
            <dd>
                @Html.DisplayFor(model => model.StudentName)
            </dd>
    
            <dt>
                @Html.DisplayNameFor(model => model.StudentAddress)
            </dt>
    
            <dd>
                @Html.DisplayFor(model => model.StudentAddress)
            </dd>
    
            <dt>
                @Html.DisplayNameFor(model => model.StudentMobile)
            </dt>
    
            <dd>
                @Html.DisplayFor(model => model.StudentMobile)
            </dd>
    
        </dl>
    </div>
    <p>
        @Html.ActionLink("Edit", "Edit", new { id = Model.StudentId }) |
        @Html.ActionLink("Back to List", "Index")
    </p>
    

    Controller

      public ActionResult _DetailOnParentPage(int? id)
            {
                if (id == null)
                {
                    return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
                }
                StudentModel studentModel = db.Students.Find(id);
                if (studentModel == null)
                {
                    return HttpNotFound();
                }
                return PartialView(studentModel);
            }

    Tuesday, April 21, 2020 10:23 AM
  • User-17257777 posted

    Hi Khan_1,

    Sorry, I still can't access your resourse... It only redirect to my account after clicking your links. 

    For simplicity, you can directly copy and paste your code here.

    Best Regards,

    Jiadong Meng

    Wednesday, April 22, 2020 7:45 AM
  • User-240513752 posted

    Please check the last one, I have edited it.

    Wednesday, April 22, 2020 6:57 PM
  • User-17257777 posted

    Hi Khan_1,

    Khan_1

    @Ajax.ActionLink("Details", "_DetailOnParentPage", new AjaxOptions { })

    Because you have defined a Ajax.ActionLink at the end. You can just remove it.

    Best Regards,

    Jiadong Meng

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 23, 2020 2:44 AM