Megrez7 Megrez7 - 1 year ago 79
C# Question

Code explanation needed

I am familiar. Have a razor c# piece of code. When through pages of documentation but I cannot find out what does this code do? Understand that runs function IsSelected of Html class but what is the meaning of argument passed to it?

<li class="@Html.IsSelected(controller: "Dashboards")>

Answer Source

if I understood correctly you want to under stand what this does

 @Html.IsSelected(controller: "Dashboards")

@ tells razor to output the following to the html code by executing


the parameter is a Named or optional parameter. It is basically saying sets the value of parameter with name "controller" to "Dashboards"

The function's definition might be like

IsSelected(int notUsed = 0, string notUsed2 = null, string controller = "dead beef")

so that you can save yourself some typing instead calling IsSelected(0, null, "Dashboards")

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download