I am trying to understand how to use:
@Html.Action("GetOptions", )
What I would like to do is to pass a call to my controller and pass the parameters:
pk = "00" and rk = "00"
Can someone explain how I can do that with the Html.Action
This Html. Action renders partial view as an HTML string so we can store it in another string variable. It is string return type method so first it returns result as a string then renders result to response.
The difference between the two is that Html. RenderAction will render the result directly to the Response (which is more efficient if the action returns a large amount of HTML) whereas Html. Action returns a string with the result.
RenderAction(HtmlHelper, String, String, RouteValueDictionary) Invokes the specified child action method using the specified parameters and controller name and renders the result inline in the parent view.
You should look at the documentation for the Action method; it's explained well. For your case, this should work:
@Html.Action("GetOptions", new { pk="00", rk="00" });
The controllerName
parameter will default to the controller from which Html.Action
is being invoked. So if you're trying to invoke an action from another controller, you'll have to specify the controller name like so:
@Html.Action("GetOptions", "ControllerName", new { pk="00", rk="00" });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With