0
<ul style="padding-right:1px;" class="navigation">
            <li>@Ajax.ActionLink("Dashboard", "Dashboard", "Dashboard", new AjaxOptions() { UpdateTargetId = "detailContainer", InsertionMode = InsertionMode.Replace }, new { @class="active"})</li>
            <li>@Ajax.ActionLink("Cases", "Cases", "Cases", new AjaxOptions() { UpdateTargetId = "detailContainer", InsertionMode = InsertionMode.Replace })</li>
            <li>@Ajax.ActionLink("Reports", "Report", "Reports", new AjaxOptions() { UpdateTargetId = "detailContainer", InsertionMode = InsertionMode.Replace })</li>
        </ul>

<div class="col-xs-10" id="detailContainer">
    @Html.Action("Dashboard", "Dashboard")
</div>

I have <ul> like above. You can see on first

  • I have applied class='active' which works fine. But when I click on Dashboardafter navigating from other <li> element, Ajax.ActionLink doesn't open Dashboard view. The problem seems to be with jQuery script. I have applied following JQuery to change class='active' when <li><a> is clicked.

    $(document).ready(function () {
        var selector = '.navigation li a';
        $(selector).click(function () {
            $(selector).removeClass('active');
            $(this).addClass('active');
        });
    });
    

    But when I remove class='active' from Dashboard, navigation works fine but when I apply class it doesn't open Dashboard view.

    What is the problem?

    1 Answer 1

    1

    You are not using correct method. There is no overloaded method as ActionLink(AjaxHelper, String, String, String, AjaxOptions, Object)

    Use AjaxExtensions.ActionLink(AjaxHelper, String, String, String, Object, AjaxOptions, Object)

     <li>@Ajax.ActionLink("Dashboard", "Dashboard", "Dashboard", null, new AjaxOptions() { UpdateTargetId = "detailContainer", InsertionMode = InsertionMode.Replace }, new { @class="active"})</li>
    
    Sign up to request clarification or add additional context in comments.

    1 Comment

    O yes, my bad. Thanks Satpal

    Your Answer

    By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.