Can someone explain these lines of code?

I'm fixing bugs for some application, and I need help understanding the following lines of code:

Here, View:

@Html.RenderControlText("WFD_CONSENT")

Controller:

public static MvcHtmlString RenderControlText(this HtmlHelper htmlHelper, string controlType)
        {
            return htmlHelper.Action("ControlText", new { controlType = controlType });
        }

The parameter controlType = "WFD_CONSENT" here. I can't get what the function htmlhelper.Action() is doing here. Logically, this function RenderControlText() should be fetching some data from somewhere, but it doesn't look like it. I'm at a dead end here. This method RenderControlText() should fetch some text which I've saved somewhere, and display it.

EDIT: The Action() method has the follwing parameters: action-name and object routevalues? What's the second part: new { controlType = controlType } ? What does this routevalues do??

Answers


I can't get what the function htmlhelper.Action() is doing here.

Take a look at the following blog post from Phil Haack where he explains child actions in details.

The Html.Action helper basically executes a child action. A child action is a standard controller action except that it could be rendered in parallel with the execution of the main request.

Html.Action("SomeAction", "SomeController") means that the SomeAction will be executed on SomeController and the result of execution of this action rendered to the output.

In contrast: Html.Action("SomePartial") means that the SomePartial will directly be rendered to the output without the execution of any child controller and action.

But in both cases all the processing happens in a single client request. It's just that you have the primary controller action that is executed and rendered a view and inside this view you used the Html.Action helper to instantiate a child controller and action (which could return for example a partial view) and the result of the execution of this view is directly inserted into the output.


Need Your Help

Serializing the Same XML Attribute

c# xml

I am serializing an XML document from a class like so:

PySide TableView and Variant data - Display Role Not Displaying

pyside qtableview qabstractitemmodel qvariant

I have this code, which when i run it in PyQt it works totally fine, but when i run it in pyside things get wierd. I get all the columns and rows im supposed to, and if i go to them via scripting a...