简体   繁体   中英

How to use Html.RenderAction in SparkView Engine?

I am getting an error when I use it like this

!{Html.RenderAction("Action", "Controller")}

I had to switch to webforms view engine and replace it with

<% Html.RenderAction("Action", "Nav"); %>

to get it to work.

The error I am getting is "Cannot convert void to char"

<% Html.RenderAction("Action", "Nav"); %>

is the same as

# Html.RenderAction("Action", "Nav");

in Spark syntax. {} expression expects a result to be returned and written to the stream; RenderAction does not return nothing, it writes to the stream itself. That's why you have to call it inside code block and cannot do this inside expression.

Web forms:
<% %> = server code
<%= %> = server code that Response.Write(x) where x == statement

Spark:
# == <% %>
${} == <%= %>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM