Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • pat 124 posts 346 karma points
    Jun 14, 2017 @ 15:48
    pat
    0

    Html.ActionLink to call Surfacecontroller action

    Hi all, I am using Html.ActionLink in my view and calling action in a surface controller

    here is my actionlink

      @Html.ActionLink("htmlAL view", "EditUser", "ListUsersController", new { contactid = @item.contactid, viewonly = true }, new { title = "View User" })
    

    and here is my Controller method

     public ActionResult EditUser(string contactid, bool viewonly)
            {
                ContactModel c = new ContactModel();
                c.contactid = contactid;
                c.editmode = !viewonly;
                TempData["test"] = "call partial view";
                return PartialView("~/Views/Partials/SiteUser.cshtml", c);
            }
    

    but noting happenes other than page refresh.

  • John Bergman 483 posts 1132 karma points
    Jun 14, 2017 @ 22:12
    John Bergman
    0

    What is the name of the class that your controller is in?

    If it is "ListUsersSurfaceController", you would change "ListUsersController" to "ListUsersSurface".

    If it is "ListUsersController", you would change it to "ListUsers"

    You should not include the work controller in the action link

  • pat 124 posts 346 karma points
    Jun 15, 2017 @ 08:40
    pat
    0

    Really I always get confused with these names.... Yes controller name need to be ListUsers ...thank you very much John

    Fullname is ListUsersController

    but this load partial view without master page layouts , i have lost the site layout.

    If I use AjaxActionLink I can load partial viewwith in layout.

      @Ajax.ActionLink("AjaxAL", "ViewSiteUserAjax", "ListUsers", new { contactid = @item.contactid, viewonly = true }, new AjaxOptions { UpdateTargetId = "mylistcontent", InsertionMode = InsertionMode.Replace, HttpMethod = "GET" }, new { title = "View User" })
    

    Do you know why I loose layout while using Html.ActionLink ?

Please Sign in or register to post replies

Write your reply to:

Draft