Convert the syntax of razor @ to ASPX <%: %

2019-05-30 14:16发布

问题:

I need to know whether the Razor and ASPX syntax are both correct

Razor:

columns.Template(@<text>@Html.ActionLink("Create Facility", "Facility")</text>)

Web Forms:

columns.Template(<%: <text><%:Html.ActionLink("Create Facility", "Facility") %> </text> %>)

回答1:

Your Razor code seems fine:

columns.Template(@<text>@Html.ActionLink("Create Facility", "Facility")</text>)

WebForms needs a little more spaghetti code:

columns.Template(c => { %> <%= Html.ActionLink("Create Facility", "Facility") %> <% })