0

I work on my mvc5 project.

I have this action method:

    public PartialViewResult Login(string returnUrl)
    {
        ViewBag.ReturnUrl = returnUrl;
        return PartialView();
    }

HTML:

 <div id="result"></div>

I need to access to the action type above and to put the returned result in div.

How can I implement it?Can I use any HTML helpers?

DodgyCodeException
  • 5,963
  • 3
  • 21
  • 42
Michael
  • 13,950
  • 57
  • 145
  • 288
  • https://learn.microsoft.com/en-us/aspnet/core/mvc/views/partial This might be usefull. – Dimitri Bosteels Nov 13 '17 at 11:05
  • @DimitriBosteels I tryed this @Html.RenderPartial(""); but it didnt helped me because I need to access to the action and not to the view. – Michael Nov 13 '17 at 11:21
  • You need to put the name of the action as first parameter (Login in your case I think) And you can pass your model as second parameter if you need to pass data – Dimitri Bosteels Nov 13 '17 at 11:24
  • Check this post if you want : https://stackoverflow.com/questions/21089917/how-to-return-partial-view-of-another-controller-by-controller – Dimitri Bosteels Nov 13 '17 at 11:25
  • 1
    use `@Html.Action()` or `@{ Html.RenderAction(); }` if you want to call a server method that returns a partial view - e.g `@Html.Action("Login", yourControllerName, new { returnUrl = someValue })` –  Nov 13 '17 at 11:38

0 Answers0